Write a program that controls the built-in LED board in the Build&Code UNO board. Make that the LED is constantly blinking, in order to make a simple visual communication with the Build&Code UNO board and make sure it works correctly.
DIFFICULTY LEVEL: Beginner.
DURATION OF THE EXERCISE: 30 min.
- 1 LED
- 1 Resistencia 220
- 1 Potenciómetro
- 1 Placa Build&Code UNO
- 1 ProtoBoard
What is a LED?
A LED is a light-emitting diode and it emits light when electricity passes through it. It has an Anode and a Cathode. The anode is the positive side and the cathode is the negative side.
You can distinguish between the anode and the cathode by looking at its legs. The larger leg is the anode and the shorter leg is the cathode. The electricity can only pass through in one direction, from the anode to the cathode, and for it to pass through it is essential that the voltage is higher in the anode than in the cathode.
- The protoboard will receive the electricity from the 5V pin of the Build&Code UNO, and then it will go back to the Build&Code UNO through the GND pin (Ground). This is why all the GNDs of the circuit must be connected to each other in order for them to have the same GND value. In the image, the GND is represented with a black cable, where all the components are connected to each other and to the GND board. The red cable represents the 5V, that feeds both the servomotor and the potentiometer.
- Connect the potentiometer central pin to an analog pin, because the potentiometer is an analog sensor. In the image you will see a blue cable connecting the potentiometer to the analog pin A0. This cable transmits information from the potentiometer to the board in order to read the values of the sensor.
- Connect the LED to a PWM digital pin, which is the one that will control the LED brightness depending of the information received from the sensor (potentiometer). The image shows how the LED connects to the digital pin PWM with a blue cable.
You can do this project using the Arduino program or a visual programming software by blocks compatible. Below you will find the necessary code.
To turn on and off the LED board which is set in the digital pin number 13, you will have to designate this pin as an output. Once you have designated it, to turn it on you have to give it a high value (HIGH or 1) and to turn it off you have to give it a low value (LOW or 0). And between each on and off the LED will stay in that state (on or off) for a second. This way you will see blinking effect.
- Download and install the Arduino IDE program. It is available for Windows, Mac OS and Linux.
- Open the Arduino program and copy the following program in it:
Code for the visual programming software by blocks compatible
- Download and install the program.
1.1 Open the software.
1.2 Configure the program to save code into the Build&Code UNO board. You will find the instructions in the Arm Robot First Steps guide.
- Open the program and copy the following code. Use the following image as a guide:
RESULT OF THE EXERCISE
The LED board integrated in the Build&Code UNO board will turn on and off according to the defined time intervals. This way, you will make sure that the Build&Code UNO board is working correctly.