Hello Friends-
I'm having an issue with a "proof of concept" program as I'm starting work on a new project.
I'm using the Toggle library to detect when a switch is open or closed. Wiring is simple- I have two wires connected to the Uno, one to Pin 7 and the other to GND. My anticipated behavior is that when the two wires are touched together (simulating a pressed switch) I'll get "Closed" on the serial monitor, and when they're not touching I'll get "open." However, I just get a long string of "Open" regardless of whether the two wires are shorted or not.
Hopefully I've just got something simple messed up but I can't find it.
Thanks for any help!
Josh
#include <Toggle.h>
int stopPin = 7;
Toggle(stopSwitch);
void setup() {
stopSwitch.begin(stopPin);
Serial.begin(9600);
}
void loop() {
if (stopSwitch.isPressed()) {
Serial.println("Closed");
}
else {
Serial.println("Open");
}
}