Panel Cookies
Arduino watch PCB - push buttons CODE
Help me by sharing this post



This is the code used with my Arduino watch development board fot the push buttons example. You will also need the OLED screen libraries so download those from below and install them before compiling the code. Download the code or copy it from below and uplaod it to the PCB.


Push buttons code: (last update 20/01/2019)

Download Adafruit_GFX library:
Download Adafruit_SSD1306 library:



Arduino smartwatch PCB code





#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>


#define TOP_BUTTON 2
#define MID_BUTTON 4
#define BOT_BUTTON 3

#define OLED_RESET 9
Adafruit_SSD1306 display(OLED_RESET);

void setup() {
  pinMode(TOP_BUTTON,INPUT);
  pinMode(MID_BUTTON,INPUT);
  pinMode(BOT_BUTTON,INPUT);

  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3C (for the 128x32)
  delay(100);
  display.clearDisplay();
  display.display();

}

void loop() {
  if(digitalRead(TOP_BUTTON))
  {
    display.clearDisplay();
    display.setTextSize(1);
    display.setTextColor(WHITE);  
    display.setCursor(0,0);
    display.print("TOP BUTTON"); 
    display.display();
  }

  if(digitalRead(MID_BUTTON))
  {
    display.clearDisplay();
    display.setTextSize(1);
    display.setTextColor(WHITE);  
    display.setCursor(0,25);
    display.print("MIDDLE BUTTON"); 
    display.display();
  }

  if(digitalRead(BOT_BUTTON))
  {
    display.clearDisplay();
    display.setTextSize(1);
    display.setTextColor(WHITE);  
    display.setCursor(0,50);
    display.print("BOTTOM BUTTON"); 
    display.display();
  }

  if(!digitalRead(TOP_BUTTON) && !digitalRead(MID_BUTTON) && !digitalRead(BOT_BUTTON))
  {
    display.clearDisplay();    
    display.display();
  }

}








yt_link
insta_link
fb_link
twitter_link

Arduino watch PCB



Affiliate Disclosure

ADVERTISERS



PCBWAY PCB service





Curso Arduino Online nivel bajo