SPEEDsSTACK Stopwatch
Intro: SPEEDsSTACK Stopwatch
In this instructable i will show how to make a touch sensitive stopwatch like the SpeedStack's stopwatch.
STEP 1: Supplies:
* Arduino pro mini
* Adafruit OLED screen (128*68 i2c)
* Copper tape
* 2 Leds
* 2 10 Kohm resistors
* 3 220 ohm resistors
* Wire
****** NOTICE: The touch sensitive are actually made of copper tape and resistor using the CapSense lib.
Also, usually i use the Arduino UNO at the planing and designing state and when done change to Arduino Pro Mini
STEP 2: Used Libraries :
I used several of them :
1. For the capacitive touch i used the CapSense library.
2. For the OLED display i used several of them that requier each other :
SPI.h - The library is used to communicate over SPI protocol.
WIRE.h - Used to communicate over I2C protocol
Adafruit-GFX-Library - Used to work with the OLED display.
Adafruit_SSD1306 - Used for the monochrome OLED based on SSD1306 drivers.
STEP 3: CODE :
#include
#include #include #include #include
#define OLED_RESET 4 Adafruit_SSD1306 display(OLED_RESET);
#define Red 7 #define Green 8 #define ResetB 6 #define Sensitive 20 #define delayRun 2000 #define blinkDelay 75
#if (SSD1306_LCDHEIGHT != 64) #error("Height incorrect, please fix Adafruit_SSD1306.h!"); #endif
CapacitiveSensor cs_4_2 = CapacitiveSensor(5, 4); // 10M resistor between pins 4 & 2, pin 2 is sensor pin, add a wire and or foil if desired CapacitiveSensor cs_4_6 = CapacitiveSensor(3, 2); // 10M resistor between pins 4 & 6, pin 6 is sensor pin, add a wire and or foil
boolean hold = false, runT = false; long holdTime, stopWatch; long total1 ; long total2 ; long calculator, blinkCount = 0, over; int Hours, Minuts, Seconds, Tseconds;
void setup() { cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF); // turn off autocalibrate on channel 1 - just as an example Serial.begin(9600); pinMode (Red, OUTPUT); pinMode (Green, OUTPUT); display.begin(SSD1306_SWITCHCAPVCC, 0x3C); display.clearDisplay(); display.setTextSize(2); display.setTextColor(WHITE); display.setCursor(0,0); }
void loop() { // *** Read touch-sensors long total1 = cs_4_2.capacitiveSensor(30); long total2 = cs_4_6.capacitiveSensor(30); //display.clearDisplay(); display.setCursor (0,0); display.print ("SPEEDsTACK"); display.display(); // *** A touch bouth sides if (total1 >= Sensitive && total2 >= Sensitive && hold == false) { digitalWrite (Green, HIGH); digitalWrite (Red, HIGH); holdTime = millis() + delayRun; // Serial.print ("holdTime = "); display.clearDisplay(); display.setCursor (0,0); display.print ("SPEEDsTACK"); display.setCursor(0,30); display.print ("--READY--"); display.display(); hold = true; }
// *** Go green light after delay if (millis() >= holdTime && hold == true) { digitalWrite (Green, HIGH); digitalWrite (Red, LOW); display.clearDisplay(); display.setCursor(10,30); display.print ("** GO **"); display.display(); while (hold == true) { //Serial.println ("hold loop"); // *** Waiting for bouth untouched while (total1 >= Sensitive && total2 >= Sensitive && hold == true) { total1 = cs_4_2.capacitiveSensor(30); total2 = cs_4_6.capacitiveSensor(30); delay (10); } total1 = cs_4_2.capacitiveSensor(30); total2 = cs_4_6.capacitiveSensor(30); // *** Wating for re-touch while (total1 <= Sensitive || total2 <= Sensitive && hold == true) { if (runT == false) { Serial.println (" *** Zeroing ***"); stopWatch = millis() + 10; runT = true; blinkCount = 0; } total1 = cs_4_2.capacitiveSensor(30); total2 = cs_4_6.capacitiveSensor(30); calculator = millis() - stopWatch; //display.clearDisplay(); //display.setCursor(0,0); //display.print (calculator); //display.display(); Hours = int(calculator / 3600000); over = calculator % 3600000; Minuts = int(over / 60000); over = over % 60000; Seconds = int(over / 1000); Tseconds = over % 1000; display.clearDisplay(); display.setCursor (0,0); display.print ("SPEEDsTACK"); display.setCursor(0,30); display.print (Hours); display.print (":"); display.print (Minuts); display.print (":"); display.print (Seconds); display.print (":"); display.println (Tseconds); display.display(); if (calculator >= blinkCount + blinkDelay) { Serial.println ("***BlinK***"); digitalWrite (Green, !digitalRead (Green)); blinkCount = calculator; } } if (runT == true) { stopWatch = millis() - stopWatch; Hours = int(stopWatch / 3600000); over = stopWatch % 3600000; Minuts = int(over / 60000); over = over % 60000; Seconds = int(over / 1000); Tseconds = over % 1000; display.clearDisplay(); display.setCursor (0,0); display.print ("SPEEDsTACK"); display.setCursor(0,30); display.print (Hours); display.print (":"); display.print (Minuts); display.print (":"); display.print (Seconds); display.print (":"); display.println (Tseconds); display.display(); hold = false; runT = false; digitalWrite (Green, LOW); blinkCount = millis(); while (!digitalRead (ResetB)) { if (millis() >= blinkCount + blinkDelay) { // Serial.println ("***BlinK***"); digitalWrite (Green, !digitalRead (Green)); digitalWrite (Red, !digitalRead (Green)); blinkCount = millis(); } } } } }
// *** A touch only one side if (total1 >= Sensitive && total2 <= Sensitive || total1 <= Sensitive && total2 >= Sensitive) { digitalWrite (Green, LOW); digitalWrite (Red, HIGH); hold = false; display.clearDisplay(); display.setCursor (0,0); display.print ("SPEEDsTACK"); display.setCursor(32,30); display.print ("<<<>>>"); display.display(); Serial.print (total1); Serial.print ("\t"); Serial.println (total1); Serial.println ("ONE Touch"); }
//*** No touch at all if (total1 <= Sensitive && total2 <= Sensitive) { digitalWrite (Green, LOW); digitalWrite (Red, LOW); display.clearDisplay(); display.setCursor (0,0); display.print ("SPEEDsTACK"); hold = false; Serial.println ("NO Touch"); }
/* Serial.print(total1); // print sensor output 1 Serial.print("\t"); Serial.println(total2); // print sensor output 2 */ delay(10); // arbitrary delay to limit data to serial port }
STEP 4: Placing and Painting
After all the electronics was set I placed all the componets and wires using 3M dubble sided tape and a regular electric tape.
Then I designed and printed a sicker, and sicked it to the stopwatch.
The area were the sticker does not cover, i painted using PlastiDip paint.
9 Comments
0705vaibhav 3 years ago
0705vaibhav 3 years ago
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
AlbharathEinstein 7 years ago
Hi, I really love your project. I am now building the same but I am using an LCD keypad shield so any idea how to conenct the rest of the parts to the shield.
0705vaibhav 3 years ago
udubinsky 7 years ago
Hi,
I never used the LCD keypad shield, but i know there are lots of libs and guide to use it, it will probebly take some twiking of my code to adjust it to the keypad but it should work.
AlbharathEinstein 7 years ago
0705vaibhav 3 years ago
udubinsky 3 years ago
0705vaibhav 3 years ago