Loading the figure…
Stopped · Your code isn't running yet. Until you press Run, the board runs the program already on it.
Nothing printed yet. Press Run.
Not checked yet
Run your code to check it. The checks replay a fixed script on a virtual clock, so the same code always gets the same result.
Each fault really happens in the simulation. Trigger one, watch the figure, then read why.
Play the world: press, slide and turn the parts while the code runs.
Change a value here or click a chip in the code.
Hard and flat at the front: a clean echo.
Put the distance sensor and a traffic light together: green when there is room, yellow when it gets close, red when it's time to stop.
| Pin | Connects to | What it does |
|---|---|---|
5V-GND | The sensor's VCC and GND, and the light's GND | Power. |
D9-D10 | The sensor's TRIG and ECHO | Ping out, echo back. |
D4 | The light's R | Red: stop. |
D3 | The light's Y | Yellow: slow down. |
D2 | The light's G | Green: keep going. |
Sensors and actuators this board drives, with the real connections.
Between D2 and GND with pinMode(2, INPUT_PULLUP): reads LOW while pressed. With an external pull-down to GND and the button to 5 V it reads HIGH while pressed instead.
| Part pin | Board pin |
|---|---|
| 1 | D2Wire colour blue |
| 3 | GNDWire colour black |
GND to GND, R to D4, Y to D3, G to D2. The module has its own resistors, so the pins drive it directly.
| Part pin | Board pin |
|---|---|
| GND | GNDWire colour black |
| R | D4Wire colour orange |
| Y | D3Wire colour yellow |
| G | D2Wire colour green |