My Analog and digital Button Library

Hi girls and boys, I just finished a nice little newbie friendly and super easy to use Analog and digital Button Library. take a look if you need one.

Analog Button Example:

#include <button.h>
button juno(A7);             //setup Analog buttons @ pin A7. (juno) you can use any word

  void setup() {
}

  void loop() {
  juno.buttonWatchdog(); // Analog Pin scans (ps, dogs are like analog things, while robot, bots are digital.)
  
  if(juno.buttonRead==1){;}  // First Analog button short-press(50ms), do whatever 
  if(juno.buttonRead==2){;}  // Second Analog button short-press, do whatever 
  if(juno.buttonRead==3){;}  
  if(juno.buttonRead==4){;}  //....add up to 10 buttons
                           
  if(juno.br==-1){;}        // First Analog button long-press (500ms), do whatever
  if(juno.br==-2){;}        // Second Analog button long-press, do whatever 
  if(juno.br==-3){;}  
  if(juno.br==-4){;}        //....add up to 10 buttons

 // br is the shortcut for buttonRead; They are same thing.  
}

Digital Button Example:

#include <button.h>
button juno(7);             //setup a digital button @ pin 7.  (juno) you can use any word
button tina(8);             //setup a digital button @ pin 8.  (tina) you can use any word

  void setup() {
}

  void loop() {
  juno.buttonWatchbot();  //digital Pin scans (ps, dogs are like analog things, while robots, bot, are digital.)
  tina.buttonWatchbot();  //digital Pin scans (ps, dogs are like analog things, while robots, bot, are digital.)
  
  if(juno.buttonRead==1){;}  // if button @ pin 7 short-press(50ms), do whatever 
  if(tina.buttonRead==1){;}  // if button @ pin 8 short-press(50ms), do whatever 
                  
  if(juno.br==-1){;}        // if button @ pin 7 long-press (500ms), do whatever                   
  if(tina.br==-1){;}        // if button @ pin 8 long-press (500ms), do whatever
  
 // br is the shortcut for buttonRead; They are same thing.  
  
}

Juno-Button.zip (14.2 KB)

This really belongs in the Exhibition/Gallery forum, as there is no question.

I'm surprised that you didn't add resistor values on your schematic diagram. That's not very "newbie friendly".

aarg: This really belongs in the Exhibition/Gallery forum, as there is no question.

Done.

    uint16_t tnow, tpast;

You should change the timestamps to unit32_t, timing does not work with 16 bit reliably.

I would use routines to access results or variables and make all data protected.

I would change the names, watchdogs are in no way connected to keys IMHO. Watchbots occur in Fallout 3/4, I would not expect them to read digital keys.