0% found this document useful (0 votes)
4 views20 pages

Arduino Basics: UNO & Programming Guide

The document provides a comprehensive overview of Arduino, including its definition, functionality, and applications in various fields such as IoT and smart cities. It details the Arduino UNO board, programming basics, and the use of digital and analog inputs and outputs. Additionally, it covers the Arduino IDE, programming functions, and examples of practical applications and modifications for controlling circuits.

Translated by

ScribdTranslations
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views20 pages

Arduino Basics: UNO & Programming Guide

The document provides a comprehensive overview of Arduino, including its definition, functionality, and applications in various fields such as IoT and smart cities. It details the Arduino UNO board, programming basics, and the use of digital and analog inputs and outputs. Additionally, it covers the Arduino IDE, programming functions, and examples of practical applications and modifications for controlling circuits.

Translated by

ScribdTranslations
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Theme 3.

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?

It is a small board that functions as the brain of the circuit. In many


new machines like cars or mobile phones.

2. Explain what it means for microcontrollers to follow a scheme.


input-process-output.

the microcontroller receives an input signal and then the microcontroller


process all the information and then depending on the information that is available
received and processed will provide a response or output

3. Why are microcontrollers so widely used?

because they are flexible, cheap, small, and consume little energy

4. ¿Qué es Arduino? ¿Para qué sirve?

It is a very commonly used open source microcontroller. To send commands to a


machine.

5. What are the objectives of the Arduino project?

That microcontrollers be accessible to everyone.

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

8. What are Arduino modules? Give 3 examples.

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

11. What is Arduino used for in industry?

to make prototypes of the machines and the Arduino is used as


controller.
2. The Arduino UNO board

1. What function does the Arduino microcontroller serve? What microcontroller?


Do you have the Arduino UNO board?

It is where a program and a miniaturized circuit that processes are stored.


information. It has an Atmega328P from Atmel.

2. Where is the program that controls the Arduino UNO board stored? How?
Is this program created?

In the microcontroller. It is created in the computer program.

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.

4. What is the function of the reset button?

To stop the program and make it start again

5. What needs to be done for an Arduino board to function without being


connected to a computer?

The computer program must be loaded into the motherboard's memory and connected to
a power supply.

6. How can we power external circuits of 3.3 or 5 V from the board?


Arduino?

Connecting it to the power pins of the board and to the GND

7. What are digital outputs used for? Which pins are digital outputs in
Arduino UNO?

To control external actuators. They are digital outputs from 0 to 13.

8. Explain how the analog input example works on the page


10.

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?

that digital inputs only detect 2 values: 0 and 1 while input


analog devices detect many more voltage values.

10. Does the Arduino UNO have analog outputs? Justify your answer.

It really doesn't have analog outputs, it only has simulations of them.


3. Program the board
1. What is the Arduino IDE? How do the two versions differ?
hay?

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

2. In what two ways can comments be written in the code of a


Arduino program? Write an example of each one. What for?
Is it helpful to comment the code?

putting // when it will occupy only one line or putting /* and placing it above and
below the comments

3. What is a function in programming? What is the difference between the function


setup and the loop function of Arduino?

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

5. Copy the program code from page 10 and explain it.

DigitalWrite (13, HIGH)

Delay (1000)

DigitalWrite (13, LOW)

Delay (1000)

first set pin 13 to high voltage, then place a command


so that you wait a second and then repeat the same thing but this time put it for
that does not have voltage

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.

DigitalWrite (13, HIGH)


Delay (200)

DigitalWrite (13, LOW)

Delay (200)

2. The LED should turn on for half a second and then turn off for a
second.

DigitalWrite (13, HIGH)

Delay (500)

DigitalWrite (13, LOW)

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() {

DigitalWrite (13, HIGH)

Delay (1000)

DigitalWrite (13, LOW)

Delay (1000)

7. How is the program we created on our computer transferred to


the Arduino board?

connecting it with the usb and selecting the port

8. What is visual programming? Name an editor of


visual programming for Arduino.

It is a simpler type of programming that allows the use of Arduino to be


even more accessible for people. Arduino Blocks is a program for
visual programming
4. Digital outputs
What does the Arduino microcontroller do to turn on an actuator?
connected to one of its digital outputs?

What it does is send a current of 5V.

2. What needs to be put in an Arduino program to activate the digital output?


8? And to deactivate it?

You have to put pinMode(13, OUTPUT); first and then you have to put
digitalWrite(13, HIGH) and digitalWrite(13, LOW).

3. What is a protoboard or breadboard? Draw a diagram of it.


internal electrical connections of the protoboard used in the practice.

it is a board that allows us to connect different components to make a circuit


electronic.

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

1. What function does the Arduino microcontroller serve? What microcontroller?


Do you have the Arduino UNO board?

It is where a program and a miniaturized circuit that processes are stored.


information. It has an Atmega328P from Atmel.

2. Where is the program that controls the Arduino UNO board stored? How?
Is this program created?

In the microcontroller. It is created in the computer program.

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.

4. What is the function of the reset button?

To stop the program and make it start again

5. What needs to be done for an Arduino board to function without being


connected to a computer?

The computer program must be loaded into the motherboard's memory and connected to
a power supply.

6. How can we power external circuits of 3.3 or 5 V from the board?


Arduino?

Connecting it to the power pins of the board and to the GND

7. What are digital outputs used for? Which pins are digital outputs in
Arduino UNO?

To control external actuators. They are digital outputs from 0 to 13.

8. Explain how the analog input example works on the page


10.

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?

to connect the negative poles

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?"}

it is each step we want a program to take. A flowchart is the


graphical representation of an algorithm.

5. Explain how version 1 of the program works.

It is a very simple code in which it is instructed to turn on, wait and


turn off each of the leds

6. What is a variable? What advantage does putting the variable 'timer' have in the
version 2 of the program?

It is a value that is assigned to a specific word. Which is simpler than


put the number

7. What is the reference page of the Arduino programming language?

It is a website where we can see codes of written language.

8. Look for what two values a bool type variable can have.

true y false

9. Explain how the for loop works in version 3 of the program.

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

11. What is Arduino used for in industry?

to make prototypes of the machines and the Arduino is used as


controller.
6. Digital Entries 1
1. What are digital inputs for? Briefly explain how they work.

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?

It is set in pinMode (INPUT) for input and (OUTPUT) for output.

3. What are the most common digital sensors?

they are the buttons, the limit sensors, magnetic, tilt, and
liquid level.

4. Explain the code of version 1 of the program.

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.

buttonState = digitalRead (buttonPin);

if (buttonState == HIGH) {

digitalWrite(ledPin, LOW);

else {

digitalWrite(ledPin, HIGH);

6. Modify version 1 of the program to create a timed light. When pressed


Once the button is pressed, the LED should turn on and remain on for
3 seconds. When this time is up, the LED must turn off.
automatically, like in a staircase light. To achieve this you must use
the delay() function. Write the necessary code here.

buttonState = digitalRead (buttonPin);

if (buttonState == HIGH) {
digitalWrite(ledPin, HIGH);

delay (3000)

digitalWrite(ledPin, LOW)

else {

digitalWrite(ledPin, LOW);

7. Explain how the while loop works in version 2 of the program.

what the while loop does is that while the button is pressed, the led will
turn on and off
7. Digital inputs 2

Magnetic sensors and limit switches can be used.


To control whether a door is open or not, how do they work?

they work by detecting whether they are being pressed or not

2. Explain the flowchart on page 7.

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.

It consists of sending information in 0s and 1s to the computer via Arduino. There is


what to put [Link]

4. What is the Serial Monitor of the Arduino IDE?

An information window that shows us the information that comes from


Arduino

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);

if (button1 == 0 && button2 == 0) {

doors 1 and 2 open

tone(10, 523, 1000);

digitalwrite(10, HIGH);

} else {

if (button1 == 1 && button2 == 1) {

doors 1 and 2 closed

} else {

if (button1 == 0) {

door1 open

tone(10, 523, 1000);

DigitalWrite(10, HIGH);

if (button2 == 0) {

door2 open

tone(10, 523, 1000);

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);

if (button1 == 0 && button2 == 0) {

2 buttons pressed

tone(10, 523, 1000);

if (pulsador1 == 1 && pulsador2 == 1) {

no button pressed

} else {

if (button1 == 0) {

button1 pressed

tone(10, 523, 1000);

if (button2 == 0) {

Button 2 pressed

tone(10, 523, 1000);

}
8. Replace lines 15 to 26 of the program of the mini unit with the following
code:

line 15: if (buttonState1 == LOW || buttonState2 == LOW) {


Line 16: [Link]("There are open doors.");
}
line 18: else {
línea 19: [Link]("No hay puertas abiertas.");
line 20: }

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

1. How do analog inputs differ from digital 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?

they have 6 analog inputs. A0 A1 A2 A3 A4 and A5

[Link] what happens in the simulation on page 2 when we zoom in or out.


light intensity. Why do we say that an LDR is an analog sensor?

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

4. What is a potentiometer? What is it like inside?

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.

5. How is it possible to have digital temperature sensors if temperature is


an analog parameter?
because they are sent encoded in binary code.

6. What are the functions analogRead(), [Link](), and [Link]() for?

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.

9. In version 2 of practice 2, the potentiometer is replaced by an LDR, what in


Does it change the behavior of the circuit?

Now the circuit serves as a light detector.

10. If the voltage received by an analog input on Arduino UNO is within


between 0 and 5 V, but the microcontroller "translates" it to a proportional value
ranging from 0 to 1023, how could the voltage be obtained that is in the
analog input from the value generated by the microcontroller? Modify the
program of practice 1 to show the tension. If you don't know how
solve it, look at: [Link]/built-in-examples/basics/ReadAnalogVoltage.

You might also like