EasyManuals Logo

Arduino uno User Guide

Arduino uno
27 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #9 background imageLoading...
Page #9 background image
9
Create and run this Arduino program
void setup()
{
Serial.begin(9600);
}
void loop()
{
Serial.println(digitalRead(3));
delay(250);
}
Open the Serial Monitor window. When the switch is open, you should see a train of 1's on the
screen. When closed, the 1's change to 0's. On the hardware side, when the switch is open, no
current flows through the resistor. When no current flows through a resistor, there is no voltage
drop across the resistor, which means the voltage on each side is the same. In your circuit, when
the switch is open, pin 3 is at 5 volts which the computer reads as a 1 state. When the switch is
closed, pin 3 is directly connected to ground, which is at 0 volts. The computer reads this as a 0
state.
Now try this program which is an example of how you can have the computer sit and wait for a
sensor to change state.
void setup()
{
Serial.begin(9600);
}
void loop()
{
while (digitalRead(3) == HIGH)
;
Serial.println("Somebody closed the switch!");
10K
PIN 3
+5 V
Gnd
10K
PIN 3
+5 V
Gnd

Other manuals for Arduino uno

Questions and Answers:

Question and Answer IconNeed help?

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

Arduino uno Specifications

General IconGeneral
Form factorArduino
CertificationRoHS, FC, CE
Processor model-
Processor frequency- MHz
Microcontroller modelATmega328
Microcontroller frequency16 MHz
DC input voltage7-12 V
Operating voltage5 V
DC current per I/O pin40 mA
Flash memory0.032 MB
Maximum internal memory- GB
SRAM (Static Random Access Memory)2 KB
EEPROM (Electrically Erasable Programmable Read-Only Memory)1 KB
Wi-FiNo
Number of analog I/O pins6
Number of digital I/O pins14
Weight and Dimensions IconWeight and Dimensions
Board dimensions53.4 x 68.6 mm

Related product manuals