Programming Concepts - Arduino uno User Manual

Hide thumbs Also See for uno:
Table of Contents

Advertisement

Interacting with the world has two sides. First, the designer must create electronic interface
circuits that allow motors and other devices to be controlled by a low (1-10 mA) current signal
that switches between 0 and 5 V, and other circuits that convert sensor readings into a switched 0
or 5 V signal. Second, the designer must write a program using the set of Arduino commands
that set and read the I/O pins. Examples of both can be found in the Arduino resources section of
the ME2011 web site.
When reading inputs, pins must have either 0 or 5V applied. If a pin is left open or "floating", it will read random
voltages and cause erratic results. This is why switches always have a 10K pull up resistor connected when
interfacing to an Arduino pin.
Note: The reason to avoid using pins 0 and 1 is because those pins are used for the serial communications between
the Arduino and the host computer.
The Arduino also has six analog input pins for reading continuous voltages in the range of 0 to 5
V from sensors such as potentiometers.

6 Programming Concepts

This chapter covers some basic concepts of computer programming, going under the assumption
that the reader is a complete novice.
A computer program is a sequence of step-by-step instructions for the computer to follow. The
computer will do exactly what you tell it to do, no more no less. The computer only knows
what's in the program, not what you intended. Thus the origin of the phrase, "Garbage in,
garbage out".
Program reads
Program reads
value of pins (1/0)
value of pins (1/0)
Board pins
Board pins
set to +5V/0V
set to +5V/0V
Interface
Interface
electronics change
electronics change
sensor signals into
sensor signals into
+5V/0V
+5V/0V
digitalRead(4);
digitalRead(4);
+5 V
+5 V
10K
10K
PIN 4
PIN 4
13
+5V
+5V
+5V
0V
0V
0V

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the uno and is the answer not in the manual?

Questions and answers

Table of Contents

Save PDF