Programming Arduino Getting Started with Sketches



Yüklə 5,42 Kb.
Pdf görüntüsü
səhifə8/78
tarix22.12.2023
ölçüsü5,42 Kb.
#189286
1   ...   4   5   6   7   8   9   10   11   ...   78
Arduino SimonMonk 2011

Power Connections
Next let us look at the connectors at the bottom of 
Figure 1-1
. You can read the connection
names next to the connectors. The first is Reset. This does the same thing as the Reset
button on the Arduino. Rather like rebooting a PC, using the Reset connector resets the
microcontroller so that it begins its program from the start. To reset the microcontroller
with the Reset connector, you momentarily set this pin low (connecting it to 0V).
The rest of the pins in this section just provide different voltages (3.5V, 5V, GND, and
9V), as they are labeled. GND, or ground, just means zero volts. It is the reference voltage
to which all other voltages on the board are relative.


Analog Inputs
The six pins labeled as Analog In A0 to A5 can be used to measure the voltage connected
to them so that the value can be used in a sketch. Note that they measure a voltage and not
a current. Only a tiny current will ever flow into them and down to ground because they
have a very large internal resistance. That is, the pin having a large internal resistance only
allows a tiny current to flow into the pin.
Although these inputs are labeled as analog, and are analog inputs by default, these
connections can also be used as digital inputs or outputs.
Digital Connections
We now switch to the top connector and start on the right-hand side in 
Figure 1-1
. Here we
find pins labeled Digital 0 to 13. These can be used as either inputs or outputs. When used
as outputs, they behave rather like the power supply voltages discussed earlier in this
section, except that these are all 5V and can be turned on or off from your sketch. So, if
you turn them on from your sketch they will be at 5V, and if you turn them off they will be
at 0V. As with the power supply connectors, you must be careful not to exceed their
maximum current capabilities. The first two of these connections (0 and 1) are also labeled
RX and TX, for receive and transmit. These connections are reserved for use in
communication and are indirectly the receive and transmit connections for your USB link
to your computer.
These digital connections can supply 40 mA (milliamps) at 5V. That is more than
enough to light a standard LED, but not enough to drive an electric motor directly.
Microcontroller
Continuing our tour of the Arduino board, the microcontroller chip itself is the black
rectangular device with 28 pins. This is fitted into a dual inline (DIL) socket so that it can
be easily replaced. The 28-pin microcontroller chip used on the Arduino Uno board is the
ATmega328. 
Figure 1-2
 is a block diagram showing the main features of this device.
The heart—or, perhaps more appropriately, the brain—of the device is the central
processing unit (CPU). It controls everything that goes on within the device. It fetches
program instructions stored in the flash memory and executes them. This might involve
fetching data from working memory (RAM), changing it, and then putting it back. Or, it
may mean changing one of the digital outputs from 0V to 5V.
The EEPROM memory is a little like the flash memory in that it is nonvolatile. That is,
you can turn the device off and on and it will not have forgotten what is in the EEPROM.
Whereas the flash memory is intended for storing program instructions (from sketches),
the EEPROM is used to store data that you do not want to lose in the event of a reset or
the power being turned off.



Yüklə 5,42 Kb.

Dostları ilə paylaş:
1   ...   4   5   6   7   8   9   10   11   ...   78




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin