New Noob
Posted: Thu Jan 05, 2017 1:49 pm
Hello Everyone.
I wanted to say thank you to those that helped me get started.
Anyway, hopefully once I can get up to speed, I can start contributing...
I have just spun up an OpenHab, and MTQQ servers. My first node is going to be the Three Gang Switch box at the front door. Right now I am working with the ESP8266 ESP-1 but I have a 12 in the mail for the production build. One of the plans is to make some small 25mm plastic disks into pressure switches, so I will have to deal with Button Bounce.
This is my first shoot at a Software Button Bounce, Please critique it, and let me know what you think.
I did not see anyone else take this approach.
I wanted to say thank you to those that helped me get started.
Anyway, hopefully once I can get up to speed, I can start contributing...
I have just spun up an OpenHab, and MTQQ servers. My first node is going to be the Three Gang Switch box at the front door. Right now I am working with the ESP8266 ESP-1 but I have a 12 in the mail for the production build. One of the plans is to make some small 25mm plastic disks into pressure switches, so I will have to deal with Button Bounce.
This is my first shoot at a Software Button Bounce, Please critique it, and let me know what you think.
I did not see anyone else take this approach.
Code: Select all
#include "user_interface.h"
#define BOARD_LED_PIN 2
#define BOARD_BUTTON_PIN 0
os_timer_t myTimer;
// start of timerCallback
void timerCallback(void *pArg) {
attachInterrupt(BOARD_BUTTON_PIN, SwitchLight, FALLING );
}
// Process interrupt
void SwitchLight() {
Serial.println("Button Pressed...");
detachInterrupt(BOARD_BUTTON_PIN);
digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));
os_timer_arm(&myTimer, 1000, false);
}
void setup() {
os_timer_setfn(&myTimer, timerCallback, NULL);
pinMode(BOARD_LED_PIN, OUTPUT);
pinMode(BOARD_BUTTON_PIN, INPUT_PULLUP);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println("Still Alive...");
attachInterrupt(BOARD_BUTTON_PIN, SwitchLight, FALLING);
Serial.print("BOARD_BUTTON_PIN ");
Serial.println(digitalRead(BOARD_BUTTON_PIN));
Serial.print("BOARD_LED_PIN ");
Serial.println(digitalRead(BOARD_LED_PIN));
delay(2000);
}