// Red button is used for Start & Resume
// Black button is used for reset - Not Done
// This stopwatch can show seconds only
int on = 32;
int off= 33;
int switch_status1 = 0;
int switch_status2 = 0;
int count = 0;
int x = 0;
#include <SPI.h>
#include <Wire.h>
// #include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HIGHT 64
#define OLED_RESET -1
Adafruit_SSD1306 display (SCREEN_WIDTH,SCREEN_HIGHT,&Wire,OLED_RESET);
// sensor
int sensor_pin1 = 33;
int sensor_pin2 = 32;
int sensor_read = 0 ;
void setup() {
Serial.begin(115200);
pinMode(35, OUTPUT);
pinMode(on, INPUT);
pinMode(off, INPUT);
display.begin(SSD1306_SWITCHCAPVCC,0x3c ); //(0x3c) This is Adress
delay (3000);
display.clearDisplay();
}
void loop() {
digitalWrite(35, HIGH);
switch_status1 = digitalRead(25);
switch_status2 = digitalRead(33);
sensor_read = analogRead(sensor_pin1);
Serial.print("SENSOR Value1 : ");
Serial.println( sensor_read);
sensor_read = analogRead(sensor_pin2);
Serial.print("SENSOR Value 2 : ");
Serial.println( sensor_read);
// display.setTextSize(2.5); // Font Size
// display.setTextColor(WHITE); // Font Colour // Not:coloUr
// display.setCursor (16,0); //Text start in this position
// display.println("STOPWATCH");
// display.println(sensor_read);
// display.display();
// delay (1);
// display.clearDisplay();
if (switch_status1 == 1)
{
Serial.println("ON");
count = count + 1;
x = x + 1 ;
Serial.println (x) ;
delay(100);
//display.println (x) ;
//delay(100);
display.setTextSize(2.5); // Font Size
display.setTextColor(WHITE); // Font Colour // Not:coloUr
display.setCursor (16,0); //Text start in this position
display.println("STOPWATCH");
display.println(x);
display.display();
delay (1000);
display.clearDisplay();
// Float and stop (reset)
}
if (switch_status1 == 1)
{
int count = 0;
int x = 0;
}
}