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