SPEEDsSTACK Stopwatch
![temp_-715441005.jpg](/proxy/?url=https://content.instructables.com/FPR/ED2V/IE2FVYS8/FPRED2VIE2FVYS8.jpg&filename=temp_-715441005.jpg)
In this instructable i will show how to make a touch sensitive stopwatch like the SpeedStack's stopwatch.
Supplies:
![speedstack_bb.jpg](/proxy/?url=https://content.instructables.com/FP2/GAKD/IE6H8EL1/FP2GAKDIE6H8EL1.jpg&filename=speedstack_bb.jpg)
![temp_1962800281.jpg](/proxy/?url=https://content.instructables.com/FM6/UTAE/IE2FVYSA/FM6UTAEIE2FVYSA.jpg&filename=temp_1962800281.jpg)
![temp_-463543038.jpg](/proxy/?url=https://content.instructables.com/F9E/FMUQ/IE2FVYSD/F9EFMUQIE2FVYSD.jpg&filename=temp_-463543038.jpg)
![temp_1263567936.jpg](/proxy/?url=https://content.instructables.com/F9X/VTXV/IE2FVYSE/F9XVTXVIE2FVYSE.jpg&filename=temp_1263567936.jpg)
![temp_978471535.jpg](/proxy/?url=https://content.instructables.com/FEM/M6VU/IE2FVYSH/FEMM6VUIE2FVYSH.jpg&filename=temp_978471535.jpg)
![temp_1003131874.jpg](/proxy/?url=https://content.instructables.com/F4R/91IS/IE2FVYSN/F4R91ISIE2FVYSN.jpg&filename=temp_1003131874.jpg)
![temp_-1217089788.jpg](/proxy/?url=https://content.instructables.com/FB0/R4NY/IE2FVYSI/FB0R4NYIE2FVYSI.jpg&filename=temp_-1217089788.jpg)
![temp_1619438817.jpg](/proxy/?url=https://content.instructables.com/F75/DEW9/IE2FVYS9/F75DEW9IE2FVYS9.jpg&filename=temp_1619438817.jpg)
* 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
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.
CODE :
![logo_arduino.jpg](/proxy/?url=https://content.instructables.com/FXX/QPH2/IE6H8E94/FXXQPH2IE6H8E94.jpg&filename=logo_arduino.jpg)
#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 }
Placing and Painting
![sticker.jpg](/proxy/?url=https://content.instructables.com/FN2/579L/IE6H8FDR/FN2579LIE6H8FDR.jpg&filename=sticker.jpg)
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.