Hardware Reference
In-Depth Information
3.2.2 Writing Program
Now we can write program. Run Arduino Sketch and write this code.
int
led =
8
;
int
button =
9
;
int
val =
0
;
void
setup
() {
pinMode(led, OUTPUT);
pinMode(button, INPUT);
}
void
loop
() {
val = digitalRead(button);
digitalWrite(led, val);
}
Save this code as
DigitalIO
.
3.2.3 Testing
After written program, you can compile and deploy the program to the board.
For testing, you press that push button. Then, you can see LED is ON.
