Commit WIP code

This commit is contained in:
2026-01-10 19:00:22 -07:00
parent 27300d472f
commit 5ead815ef2
4 changed files with 586 additions and 0 deletions

30
demos/button/button.ino Normal file
View File

@@ -0,0 +1,30 @@
// Button Input pullup demo
// Connect to D19
// Note: no debounce logic
const int BUTTON_PIN = 19; // GIOP19 pin connected to button
// Variables will change:
int lastState = LOW; // the previous state from the input pin
int currentState; // the current reading from the input pin
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(115200);
// initialize the pushbutton pin input
// the pull-up input pin will be HIGH when the switch is open and LOW when the switch is closed.
pinMode(BUTTON_PIN, INPUT_PULLUP);
}
void loop() {
// read the state of the switch/button:
currentState = digitalRead(BUTTON_PIN);
if(lastState == HIGH && currentState == LOW)
Serial.println("The button is pressed");
else if(lastState == LOW && currentState == HIGH)
Serial.println("The button is released");
// save the the last state
lastState = currentState;
}