# Mini-Tutorial: WokWi MicroPython Simulation
###### tags: `TA Stuff RP2` `Raspberry Pi Pico`
While you are waiting for the Raspberry Pi Pico W (RP2040), you can still practice concepts that we are learning in the course.
## Emulating RP2040 with WokWi
Wokwi is an open-source simulator for Arduino, ESP32, STM32, and other microcontroller projects. We will be using the **MicroPython simulator** for the Raspberry Pi Pico W (RP2040):
https://wokwi.com/projects/new/micropython-pi-pico
Let's look at the [pinout diagram](https://datasheets.raspberrypi.com/picow/PicoW-A4-Pinout.pdf) for the Raspberry Pi Pico W board:

The physical pin locations are numbered 1 through 40. There are labels at each pin to indicate what kind of communication the pins support.
Connect the 3V3 pin to the top (+) rail. Connect a GND pin to the (-) rail. Connect the GP16 pin to [the anode (longer wire) of the LED](http://cmra.rec.ri.cmu.edu/products/electronicsv2/basic_components/what_is_an_led/1/vid1.html). Finally, add a resistor to reduce the current to the LED (220 or 330 Ohm, typically).

Here is the code that you will need:
```
# Import libraries
from machine import Pin # import Pin definitions
import time # import timer library
# define GP16 as output pin
redLED = Pin(16, Pin.OUT)
# start loop
while True:
redLED.on() # turn on red LED
time.sleep(0.3) # wait 0.3 seconds
redLED.off() # turn off red LED
time.sleep(0.8) # wait 0.8 second
```
If everything is wired correctly, you can start the simulation!
Completed tutorial here:
https://wokwi.com/projects/400021799366179841
:warning: **Note:** You will not be able to access your home Wi-Fi network from the emulator.
:warning: **Note:** Not all sensors are available for simulation in WokWi, such as the DHT11.
:warning: **Warning:** The simulator may not have the same pin layout as your physical devices. Always refer to the manufacturer datasheet!
## About WokWi
[Wokwi](https://wokwi.com/) is an open-source simulator for Arduino, ESP32, STM32, and other microcontroller projects. It typically supports Arduino code (C/C++), but we are using an experimental feature which supports MicroPython with the Raspberry Pi Pico W (RP2040).
1. Create a sketch by selecting a template.
2. Add the breadboard, sensors, actuators, and connect with wires.
3. Write the relevant code.
4. Click Run to simulate the real-time behavior.
### Keyboard shortcuts
Pressing number keys while wiring will change the color of that wire (0-black, 2-red):
https://docs.wokwi.com/guides/diagram-editor#changing-the-color-of-a-wire
Esc - cancel wiring, or exit parts menu
R - rotate a part
D - duplicate a part
Delete - delete a part
Ctrl+Z - undo
Ctrl+Y - redo
https://docs.wokwi.com/guides/diagram-editor#keyboard-shortcuts