-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbutton.ino
More file actions
48 lines (42 loc) · 1 KB
/
button.ino
File metadata and controls
48 lines (42 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
[ATmega32U4 Pinout]
----------
TX=1-| ProMicro |-RAW
RX=0-| |-GND
GND-| |-RST
GND-| |-VCC
SDA=2-| |-21=A3
SCL=3(~)-| |-20=A2
A6=4-| |-19=A1
5(~)-| |-18=A0
A7=6(~)-| |-15=SCLK
7-| |-14=MISO
A8=8-| |-16=MOSI
A9=9(~)-| |-10(~)=A10
----------
*/
#define ledPin 17 // RX_LED
#define buttonPin 2
bool buttonState = 0;
void setup()
{
Serial.begin(115200);
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT_PULLUP);
}
void loop()
{
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH)
{
digitalWrite(ledPin, HIGH); // turn LED on:
}
else
{
digitalWrite(ledPin, LOW); // turn LED off:
}
Serial.print("buttonState[");
Serial.print(buttonState);
Serial.println("] ");
delay(1000);
}