filmov
tv
Arduino Uno example Digital Read Serial

Показать описание
Tutorial:
Require Components:
1x Arduino Uno
1x push button 4 leg
2x Wires: red for 5v, yelllow for pin 2
Steps:
1. use red wire connect pin 5v & push button
2. use 10k resistor to connect other button leg to pin GND
3. use yellow wire to connect other button leg to pin 2
4. connect usb cable
Note:
1. When do nothing, value = 0 = LOW
2. When press the button, value = 1 = HIGH
Code:
int pushButton = 2;
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
// make the pushbutton's pin an input:
pinMode(pushButton, INPUT);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input pin:
int buttonState = digitalRead(pushButton);
// print out the state of the button:
delay(1); // delay in between reads for stability
}
Require Components:
1x Arduino Uno
1x push button 4 leg
2x Wires: red for 5v, yelllow for pin 2
Steps:
1. use red wire connect pin 5v & push button
2. use 10k resistor to connect other button leg to pin GND
3. use yellow wire to connect other button leg to pin 2
4. connect usb cable
Note:
1. When do nothing, value = 0 = LOW
2. When press the button, value = 1 = HIGH
Code:
int pushButton = 2;
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
// make the pushbutton's pin an input:
pinMode(pushButton, INPUT);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input pin:
int buttonState = digitalRead(pushButton);
// print out the state of the button:
delay(1); // delay in between reads for stability
}