Which pins are red, yellow, and green?
In the Traffic Light sample, GP14 is red, GP15 is yellow, and GP16 is green. Each LED needs a resistor of about 220 ohms in series, the same classroom note as the button sample.
Free ($0) is the block builder and the Pico W simulator. Standard ($30/month) adds ESP32, Raspberry Pi, Makeblock, USB upload, and .py downloads. Premium ($50/month) adds online project saves.
Three small projects teach output, input, and sound. The Traffic Light sample cycles red, yellow, and green. The Button Controls LED sample turns an LED on while a button is pressed. A buzzer block plays a tone on a pin you choose. Start with the lights in the Pico W simulator. Add wires only with an adult.
Open Samples and choose Traffic Light. It is in Basics. On start, the blocks set GP14, GP15, and GP16 as outputs. A forever loop then does this. GP14 on, GP15 off, GP16 off, wait 3000 milliseconds. GP14 off, GP15 on, wait 1000 milliseconds. GP15 off, GP16 on, wait 2000 milliseconds. GP16 off. Then the loop starts again. The sample tips name the colors: GP14 is red, GP15 is yellow, and GP16 is green.
That pattern is only pin writes, so the simulator can show it. Press Simulate, then Run Blocks, and read the terminal. You will see lines like [pin] GP14 -> HIGH. The first pin write also points the Virtual Lamp at that pin. The waits show up as simulated delays. The screen is the result of the run, not a traffic light that keeps cycling on its own.
The Button Controls LED sample is the input project. A button on GP15 and an LED on GP14 sit inside a forever loop with a 50 millisecond wait. If the button block says pressed, GP14 is on. Otherwise GP14 is off. The block reads the pin with a pull-up, and pressed means the value is 0. Wire the button between GP15 and GND. The LED tip says GP14, then a resistor of about 220 ohms, then the LED, then GND. The resistor has to be in series. Use about 220 ohms for each traffic-light LED too. That note is for a Pico at 3.3 volts.
Press Open Studio and leave the board on Raspberry Pi Pico W. No account is needed.
Open Samples and choose Traffic Light. Read the three pin numbers before you change anything.
Press Simulate, then Run Blocks. Use Terminal or Split. Look for [pin] GP14, GP15, and GP16.
Change a wait if you want a longer red or a shorter green. The sample tips say the delay values set how long each light lasts. Read the code panel after you change a number.
Open Button Controls LED when you are ready for a press. The simulator has no button picture, so this sample is for a real button with an adult.
Add a buzzer block on a free pin, such as GP13, if you want a beep when the light is green. The block is buzzer pin, frequency in hertz, and time in milliseconds. The simulator logs the tone. It does not play the sound.
For a real Pico W, use Chrome or Edge and press Connect Board. Keep the resistor in series with each LED.
while True:
Pin(14, Pin.OUT).value(1)
Pin(15, Pin.OUT).value(0)
Pin(16, Pin.OUT).value(0)
time.sleep_ms(3000)
Pin(14, Pin.OUT).value(0)
Pin(15, Pin.OUT).value(1)
time.sleep_ms(1000)
Pin(15, Pin.OUT).value(0)
Pin(16, Pin.OUT).value(1)
time.sleep_ms(2000)
Pin(16, Pin.OUT).value(0)
The button sample writes a pull-up read. Pressed is (Pin(15, Pin.IN, Pin.PULL_UP).value() == 0). The if branch writes Pin(14, Pin.OUT).value(1). The else branch writes value(0). A wait of time.sleep_ms(50) sits in the loop so the pin is checked again and again. The simulator does not include a control that presses GP15 for you. Build this one when you have the button and an adult for the wires.
A buzzer block writes a PWM pin, sets the frequency, holds the tone for the milliseconds you chose, then sets the duty to 0 so the tone stops. A stop buzzer block sets that duty to 0 as well. Pick a pin the traffic light is not using. GP14, GP15, and GP16 are the three lights. GP13 is a free example, not a required pin. The traffic-light tips say you can add a buzzer block when the light turns green. Put it after the green pin write if that is the moment you want.
The blink guide uses the light on the board and no extra parts. The simulator guide explains Run Blocks and the virtual lamp.
Make red last longer by changing 3000. Make the green beep by adding the buzzer only on the green step. The button sample tips also suggest a toggle, where one press leaves the LED on and the next press turns it off, or a second button for a second LED. Do those after the first if-and-else version works.
ESP32 can use the same blocks, and the code panel still shows MicroPython. The picture practice view to learn the cycle is the Pico W simulator. Connect a real ESP32 in Chrome or Edge when you move off the simulator. Read the code before you upload.
In the Traffic Light sample, GP14 is red, GP15 is yellow, and GP16 is green. Each LED needs a resistor of about 220 ohms in series, the same classroom note as the button sample.
No. There is no button picture. The traffic-light pins do show up in the log. Use a real button on GP15, wired to ground, when you want a press.
No. The simulator writes a log line with the pin, the frequency, and the time. The sound needs a real buzzer on the board.
No. Open the studio in the browser. Your blocks stay on this computer. Copy the code if you want a copy outside the browser.