Troubleshooting Help with Toggle.h Library

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");
  }

}

Thanks- here's the library link:

It claims a "fast and robust debounce algorithm."
Theoretically my thought was this would be easier to implement a few switches down the road then digital read. I'm pretty sure its looking for switch connecting the pin to Ground (there is a toggle in the library to switch it for pin to 5v but default appears be ground).

That is 100% what it is. Added it and now it behaves as expected.
I knew it was likely something simple and I have been staring at it too long.
Thanks for your assistance

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.