Arduino Basics: UNO & Programming Guide
Arduino Basics: UNO & Programming Guide
Arduino
index
1. Introduction to Arduino........................
2. The Arduino UNO board........................
3. Program the board.......................................................................................................................................
4. Digital outputs........................
1. Introduction to Arduino.
1. What is a microcontroller? Where are they used?
because they are flexible, cheap, small, and consume little energy
6. What does 'open source software' mean? And 'open source hardware'? Do they have
Is there any limit to this type of licenses?
that all the software code is published and can be taken and modified. That
all plans, materials, and construction methods. Yes, that everything they do
Other companies different from Arduino must have another name.
7. What is the name of the most used Arduino board? Name two other ones.
Arduino boards.
Arduino UNO is the most used. Arduino Yún and Arduino Nano are other boards from the
brand
They are peripherals that connect to the board for it to have a use. There are modules of
sensors, power electronics modules, communication modules
9. What is IoT? What needs to be done to use Arduino in an IoT system?
the connections that various everyday objects have with the internet in order to
control them all from a single device. Connect an internet module
10. What is a 'smart city'? Give two examples of smart city systems.
a city that uses the Internet of Things (IoT) to improve the quality of life.
For example, the buses have locators to know when they are going to arrive.
next stop and gas sensors to measure how much pollution there is in the city
2. Where is the program that controls the Arduino UNO board stored? How?
Is this program created?
3. What are the different indicator lights on the Arduino board for?
UNO?
The ON LED indicates whether it is on or off, the L can be programmed from the program.
The computer and the TX and RX LEDs indicate whether it is receiving data or not.
plate.
The computer program must be loaded into the motherboard's memory and connected to
a power supply.
7. What are digital outputs used for? Which pins are digital outputs in
Arduino UNO?
The analog input receives a voltage that is detected by the board and that
afterwards the cpu processes the information and gives a value from 0 to 1023
9. How do analog inputs differ from digital inputs?
10. Does the Arduino UNO have analog outputs? Justify your answer.
It is the program used to work with the Arduino board and create programs on it.
One is on the web and the other is a computer program
putting // when it will occupy only one line or putting /* and placing it above and
below the comments
They are sets of instructions that are executed when called from another part of the
code
4. Explain what the functions pinMode(), digitalWrite(), and delay() are used for.
pinMode serves to indicate whether the pin is in input mode or in output mode.
digitalWrite to change the voltage of a pin and delay to make it so that after
an action waits for a certain amount of time
Delay (1000)
Delay (1000)
6. Modify the program from the previous question to execute the following
acciones:
The LED should turn on and off very quickly, every 200 milliseconds.
Delay (200)
2. The LED should turn on for half a second and then turn off for a
second.
Delay (500)
Delay (1000)
3. The LED should turn on and off for 1 second, but only twice.
total, not repeatedly. This must happen every time it is turned on.
press the Reset button. A hint: The loop() function must be
empty.
void setup() {
Delay (1000)
Delay (1000)
You have to put pinMode(13, OUTPUT); first and then you have to put
digitalWrite(13, HIGH) and digitalWrite(13, LOW).
4. Draw the electrical schematic of the circuit of the practice and indicate the name of
the components.
5. Explain how the program that controls the circuit of the practice works.
what the program does is activate the output, wait 1 second, return to
deactivate it and wait a second again
6. Modify the program to make the LED in the external circuit blink.
every 250 milliseconds and test it on the board.
void loop(){
digitalWrite(13, HIGH);
delay(250);
digitalWrite(13, LOW);
2. The Arduino UNO board
2. Where is the program that controls the Arduino UNO board stored? How?
Is this program created?
3. What are the different indicator lights on the Arduino board for?
UNO?
The ON LED indicates whether it is on or off, the L can be programmed from the program.
The computer and the TX and RX LEDs indicate whether it is receiving data or not.
plate.
The computer program must be loaded into the motherboard's memory and connected to
a power supply.
7. What are digital outputs used for? Which pins are digital outputs in
Arduino UNO?
The analog input receives a voltage that is detected by the board and that
afterwards the cpu processes the information and gives a value from 0 to 1023
5. Digital outputs 2
1. Draw the electrical schematic of the circuit of the practice and indicate the name of
the components.
2. What is the GND pin used for in the circuit of the practice?
3. Determine whether these statements about the practice circuit are true or false:
a) The negative terminals of the 3 LEDs are connected to each other and with the
pin GND. true
b) The positive terminals of the 3 LEDs are connected to each other through
of interleaved resistors. False, each one is connected to a different pin.
{"algorithm":"What is an algorithm?","flowchart":"And what is a flowchart?"}
6. What is a variable? What advantage does putting the variable 'timer' have in the
version 2 of the program?
8. Look for what two values a bool type variable can have.
true y false
What it does is tell the program to change pins between 2 and less than 5
10. The circuit uses digital outputs 2, 3, and 4 to control the LEDs, how
it should be the code of version 3 of the program if the outputs are used
digital 5, 6 and 7?
9. What is IoT? What needs to be done to use Arduino in an IoT system?
the connections that various everyday objects have with the internet in order to
control them all from a single device. Connect an internet module
10. What is a 'smart city'? Give two examples of smart city systems.
a city that uses the Internet of Things (IoT) to improve the quality of life.
For example, the buses have locators to know when they are going to arrive.
next stop and gas sensors to measure how much pollution there is in the city
They serve so that the Arduino can detect what happens outside. When
they receive 5V of power the pin sends that information to the program.
2. In Arduino, the digital input pins are the same as those of the
digital outputs, how do you tell Arduino that a digital pin should work
como entrada? ¿Y como salida?
they are the buttons, the limit sensors, magnetic, tilt, and
liquid level.
What the code does is tell it that if pin 12 detects input power, pin 2
of power.
5. Modify version 1 of the program to make the LED always stay on.
turns on and off when the button is pressed. Write the necessary code here.
if (buttonState == HIGH) {
digitalWrite(ledPin, LOW);
else {
digitalWrite(ledPin, HIGH);
if (buttonState == HIGH) {
digitalWrite(ledPin, HIGH);
delay (3000)
digitalWrite(ledPin, LOW)
else {
digitalWrite(ledPin, LOW);
what the while loop does is that while the button is pressed, the led will
turn on and off
7. Digital inputs 2
first it is checked if both are being pressed, if the answer is yes then
it will be shown that the two doors are open, if the answer is no then we
will check if only door one is open, if the answer is yes then it
mostrará que la puerta 1 está abierta, si no se comprobara si la puerta 2 está abierta
if the answer is yes, it will show that door 2 is open, if the answer is no
it will be shown that the two doors are closed and then a second is waited for
repeat this process
3. What does serial communication consist of? What code do we need to put in
the program of an Arduino board to start a serial communication with
the computer to which it is connected.
5. What does the if... else if... else programming structure consist of? Give an example.
example that does not appear in the miniunit.
they function as conditions that are set for sending information. if not
One goes to the next to see if conditions are in place to send.
information
6. Add to the mini unit circuit a LED that lights up when any of
the two doors are open. Write the necessary code here. It will be of
help to revisit the previous mini-unit.
void loop()
delay(5000);
button1 = digitalRead(7);
button2 = digitalRead(12);
digitalwrite(10, HIGH);
} else {
} else {
if (button1 == 0) {
door1 open
DigitalWrite(10, HIGH);
if (button2 == 0) {
door2 open
DigitalWrite(10, HIGH)
}
7. Modify the mini-unit program so that it behaves as follows: Upon
Pressing both buttons shows: "Both buttons are pressed."
By pressing only button 1: 'Button 1 is pressed'. By pressing only the
pulsador 2: "El botón 2 está pulsado". Ningún pulsador presionado: "Ningún
The button is pressed. Write the code here.
delay(5000);
button1 = digitalRead(7);
button2 = digitalRead(12);
2 buttons pressed
no button pressed
} else {
if (button1 == 0) {
button1 pressed
if (button2 == 0) {
Button 2 pressed
}
8. Replace lines 15 to 26 of the program of the mini unit with the following
code:
What do the two parallel vertical lines after the first LOW mean?
How will this program work?
they mean that one or the other can be given and that it is not necessary for both to be given
It works by checking if there is an open door; if so, it communicates that there is.
open doors open. If not then it says that there are no open doors
8. Analog inputs
where the analog inputs detect values between 0 and 5 V while the digital ones
they detect the value 0 or 5
2. How many analog inputs does Arduino UNO have? What are the pins for them?
analog inputs?
the more light it receives, the more current flows and reaches the analog input. Yes, since
get intermediate values and not values 0 or 1
The potentiometer is a variable resistor. Inside, it has a resistive track that connects the
terminal A with C and a rotating metal plate connected to B that rubs against the resistive track.
for the analog sensor to be set to input mode, for serial communication
between the computer and the Arduino at the frequency you want and for the Arduino
send a signal to the computer
7. What are the numbers that appear on the serial monitor in practice 1? What
What happens when the potentiometer axis is turned?
the voltage that reaches the analog input. Either the numbers and the voltage increase or
decreases depending on which direction you have turned the potentiometer
8. How is it decided when to turn the LED on or off in version 1 of the practice?
2?
When the voltage that reaches the analog input is greater than or equal to 512, the LED turns off.
Otherwise, it turns off.