Lights and displaysPedestrian Crossing with a Button
Cars have green until a pedestrian presses the button. Then the cars get red, the pedestrians get green and a buzzer ticks, just like at a real crossing.
Lights and displaysWhen the room gets dark the LED switches itself on, and a knob sets the brightness. Grove modules simply plug into the shield: no soldering, no breadboard.
Written by the RoboHub team. A question? Write to us.
Choose a variation and the parts list updates.
Fit the Grove Base Shield onto the Arduino.
Plug the light sensor into A0, the knob into A1 and the LED into D3.
The program reads the light sensor: when it is dark the LED comes on, and the knob sets its brightness.

Illustration, made with AI
const int LIGHT = A0, KNOB = A1, LED = 3;
const int DARK = 300; // tune for your room
void setup() {
pinMode(LED, OUTPUT);
Serial.begin(9600);
}
void loop() {
int light = analogRead(LIGHT);
int level = map(analogRead(KNOB), 0, 1023, 0, 255);
Serial.println(light);
analogWrite(LED, light < DARK ? level : 0);
delay(100);
}Illustration: on a child's nightstand, a Grove shield on an Arduino with a light sensor, a knob and a lit LED module.
Step 3: The code
Lights and displaysCars have green until a pedestrian presses the button. Then the cars get red, the pedestrians get green and a buzzer ticks, just like at a real crossing.
SensorsAn ultrasonic sensor measures the distance. Three LEDs show how close the obstacle is, and the buzzer beeps faster the closer you get.
GamesAn LED lights at a random moment. Whoever presses their button first wins. Built from Student Kit parts in 45 minutes.