PROJECT Nº 1: Hello World

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.

MATERIALS:

  • 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.

CONNECTIONS:

  1. 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.
  2. 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.
  3. 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.

PROGRAMMING CODE

You can do this project using the Arduino program or a visual programming software by blocks compatible. Below you will find the necessary code.

Arduino 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.

  1. Download and install the Arduino IDE program. It is available for Windows, Mac OS and Linux.
  2. Open the Arduino program and copy the following program in it:
    int LEDPin =  13;      // Define that you will work with the digital PIN 13
    void setup() {
      
      pinMode(LEDPin, OUTPUT);  //Define that digital PIN 13 is an output
      
    }
    
    void loop() { // Main loop, everything that is inside here will repeat infinitely
      
      	digitalWrite(LEDPin, HIGH); // Make that PIN 13 sends an electronic pulse of 5V by using the “HIGH” value
     
    delay(1000);      // Make that the program stays in the last instruction for 1000ms (1 second). The LED will stay On for 1 second
    
      
    digitalWrite(LEDPin, LOW);  // Make that PIN 13 does not send any electronic pulse (0V) using the “LOW” value
    
      
    delay(1000);  // Make that the program stays in the last instruction for 1000ms (1 second). The LED will stay Off for 1 second.
    
    
    }
    

Code for the visual programming software by blocks compatible

  1. 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.
  2. 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.

1 0

0