ESP32 Starter Kit
3. Test Code
We simply stimulate the traffic lights: green LED lights up for 5s, yellow LED blinks for 3 times, and red LED lights
up for 5s. And we set this to loop.
The blinking of yellow LED can utilize for()statement we have mentioned in project 3. Thus, we only need to set the
lighting time to complete a traffic light.
1. Drag the two code blocks.
2. Set the pin mode to “output”
3. Drag the following blocks from “LED” part and set the IO27 pin to HIGH and then LOW. Then set the delay
time to 5s.
4. Drag the following blocks from “Control” part and set the repeat time to 3, then set the IO26 pin to HIGH and
then LOW. Then set the delay time to 0.5s.
182 Chapter 9. Scratch Tutorial