Using the serial monitor to get information from the program

The SERIAL MONITOR is very useful feature of Arduino to get information in our computer from the Arduino while a program is running. Learn how it works with the following tutorial! First you have to follow the instructions given and then do the two practice problems you can read at the end of the page:

Arduino: Serial Monitor (RoboIndia)

Finally, modify your project Interactive Traffic Lights to get the following messages in the Serial Monitor depending on the situation in which the program is:

  1. “Green for cars; red for pedestrians”
  2. “Hurry up, cars; red for pedestrians”
  3. “Red for cars; green for pedestrians”
  4. “Caution, cars; hurry up, pedestrians”


Digital outputs and inputs in Arduino

Although digital outputs in Arduino don’t have secrets for us anymore, this video is a quite good reminder.

Anyway, the most important thing in the video is that it explains how to work with DIGITAL INPUTS (i.e. a push switch). That is a little bit more complicated since we need a PULL-DOWN RESISTOR. These are the connections we need:

Connections should look more or less like the following circuit diagram:

Here comes the video:

Once you understand how to work with digital inputs and a pull-down resistor, use it to create an interactive version of the traffic lights project!

Project: traffic lights

Once we know how to work with LEDs and buzzers in Arduino, we are ready to put it into practice with an almost real project. We will simulate the way traffic light work in our city. We will do it in 4 steps:

1. Create the traffic lights that control when cars can move or must stop.

2. Add two extra LEDs to control when pedestrians can walk or must wait.

3. Add an active buzzer so blind pedestrians know when they can go across the street.

4. Add a switch so we make the traffic lights interactive: they will always be green for cars and red for pedestrians unless someone presses the switch.


This chart shows how lights have to interact in each situation:

Playing sounds with Arduino and an active buzzer

With the above circuit, write the following program, run it and then put comments in every line:

Do the same thing with the following program:

Finally, answer questions 1 and 2 in your notebook and do practice 3:

  1. Based on what you have done in program 1, what is the difference between these two instructions?
    • tone(pinBuzzer, 440);
    • tone(pinBuzzer, 523, 600);
  1. Explain in your notebook what an array is
  2. Imagine we have 5 LEDs connected to the pins 5, 6, 7, 8, 9. Write the program to make them shine one by one USING an array and a loop to pass through all the LEDs





Basic practices with Arduino and LEDs

We will use the Arduino IDE to program Arduino boards that control LEDs. This is the first set of practices, based on the ones designed by Víctor Gallego:

Practices with Arduino and LEDs

And then, let’s design some circuits and programs where you have to apply what you have learned so far:

Designing circuits with Arduino and LEDs


Resistor color code and practices with resistors

Watch this video to learn how to get the nominal resistance in a resistor:

Here you can find a resistor color code CALCULATOR: enter the number of color bands, their colors and get the nominal resistance

Resistor color code calculator

These are the practices with resistors that we will do in the workshop:

  1. Practice 8.1: Resistors
  2. Practice 8.15: Some common resistors / Calculator