1 changed files with 18 additions and 8 deletions
@ -1,18 +1,28 @@ |
|||||||
#include <Arduino.h> |
#include <Arduino.h> |
||||||
|
|
||||||
// put function declarations here:
|
int buttonPin = 2; |
||||||
int myFunction(int, int); |
int ledPin = 10; |
||||||
|
int buttonState = 1; |
||||||
|
int lastButtonState = 1; |
||||||
|
int ledState = LOW; |
||||||
|
|
||||||
|
|
||||||
void setup() { |
void setup() { |
||||||
// put your setup code here, to run once:
|
// put your setup code here, to run once:
|
||||||
int result = myFunction(2, 3); |
Serial.begin(115200); |
||||||
|
pinMode(buttonPin, INPUT); |
||||||
|
pinMode(ledPin, OUTPUT); |
||||||
|
|
||||||
} |
} |
||||||
|
|
||||||
void loop() { |
void loop() { |
||||||
// put your main code here, to run repeatedly:
|
// put your main code here, to run repeatedly:
|
||||||
|
buttonState = digitalRead(buttonPin); |
||||||
|
if (lastButtonState == HIGH && buttonState == LOW) |
||||||
|
{ |
||||||
|
ledState = !ledState; |
||||||
|
digitalWrite(ledPin, ledState); |
||||||
} |
} |
||||||
|
lastButtonState = buttonState; |
||||||
// put function definitions here:
|
delay(50); // 50ms debounce
|
||||||
int myFunction(int x, int y) { |
|
||||||
return x + y; |
|
||||||
} |
} |
||||||
Loading…
Reference in new issue