intro to electronics


What is Arduino? Arduino is an electronic
open source prototyping platform, based on
modular software and hardware, intended for everyone. As Arduino is
based on open-source hardware, there are
lots of different types of cards. The UNO, classic, much
smaller cards such as the Trinket, others,
enable Wifi connexion, like the Huzzah, or
other cards enabling radio communication. But with the Arduino,
what can we do? From interaction
with light, experimental musical instruments, or
engine checking. In the real apps, we can
make a video game table. We can make connected
hives from which we recover data on the Web. We can control engines and
make a 3D printer. So how do we use it? To programm an
Arduino, you just have to download the Arduino
software on the Arduino site, and use associated language. Finally, we connect
our Arduino in USB. Thanks to Tinkercad
Circuits, we will make the “Hello World” from Arduino, a LED
that blinks programmed by Arduino. We are thus creating a new
circuit with an Arduino and a LED. All pin codes from 0
to 13 on the Arduino, are digital inputs and outputs. So we can program them to turn a LED on or off. We are going to link the
pin 13 to the Arduino’s anode (the longest leg),
and link the cathode to the pin marked “GND” (GROUND) of the Arduino. Once our circuit
is finished, we go on the Code Editor tab to type our code. An Arduino program
is made of 2 sequences, a “setup” one, that
executes after our Arduino’s initialization, that is to
say when we turn it on, in which we will define that the
pin 13, the one on which our LED is plugged in,
will be used as an output. Then, a part “loop”
which will execute in loops, until the Arduino
has been turned off. Inside, we will define
that pin 13 will send power, wait 1 second,
we stop the power on pin 13 and
we wait 1 second again. The loop instruction will
repeat until the Arduino stops. Once the program has run,
we can send it to our Arduino. That was it for our quick
Arduino presentation, it has enabled us to make a LED blink. In the Arduino presentation,
we saw how to make a LED blink. Now, we are going to see
how to use a sensor to control it. So we’ll go in
“Components” and use a button. A button is made of
two separated metal wires. And when we press
the button, the two metal wires will be
linked by a metal bridge that enables
power to go through. So we are going
to link our button’s first wire to a 5 V, and we have
to link the second wire of our button to the big ones. Yet, linking them directly, would create a short circuit
when touching the button. But what is a short circuit? It means that when the
plus and the minus of an energy source are linked together,
there is no charge to use the energy of
your power supply, it may overheat and explode. So we have to use a 10KOhm resistor to enable us to use the
energy that goes through the button. We can change
a resistor’s value in the information box. So we are going
to put a 10Kohm resistor. So we can link the
button to the resistor, then the resistor to the big
ones, without any short circuit risk. We can use any
pin from 0 to 13 to read a digital signal. We will use
the pin 7 to do the power supply reading at
our button’s output but before the resistor. And that’s all for our circuit. Now, let’s do the code. So we have the “setup”
part with the initialization of pin 13 as output,
to send power to our LED, and we have the “loop” part
which repeats until our Arduino stops, that enables to
turn on the pin 13, to wait 1 second,
to turn off pin 13’s power, and wait one more second. We’d like to read
pin 7’s power flow, so we will use “pinMode” function,
to define pin 7 as input. In the “loop” part,
we will decide that the LED only flickers when
power flows through pin 7. If the reading, of the pin 7
equals “HIGH”, that is to say there’s a power flow,
so we will turn pin 13 on, wait 1 second,
turn pin 13 off, wait one more second and
we’ll close the curly bracket, to say all these actions
will be executed only if the digital reading is on “HIGH”, that is to say
that the power flows in. Now, all we
have to do is upload and make our code run. We have seen how
to use inputs and outputs on Circuits, it would be
the same thing with Arduino. Now, it’s your turn to create.

Leave a Reply

Your email address will not be published. Required fields are marked *