TimerLEDBox

From NebarnixWiki
Jump to: navigation, search

Problem Statement

At Heatsync Labs we host a micro-conference every few months called 'Hot Topics' where the speakers talk for 10 minutes followed by a 5 minute QA. Many of the speakers went on for nearly an hour and used up the time allocated to other speakers. Wouldn't it be neat to have a way to track time but not in a way that is interruptive or confrontational? I want to make a system where the presenter knows exactly how much time is left on the clock, and can use the simple readout to mark certain 'temporal waypoints' they need to reach (IE a slide or a topic) in order navigate their topic space within the allocated time.

System Overview

This cat is not a button, nor 3D printed, and is for illustrative purposes only

The box holds 5 color changing LEDs and a button that is also a 3D printed cat. As time ticks down, the LEDs, which start all green, turn yellow one by one. Once all of the LEDs are yellow, they turn red one by one. Once all LEDs are red, they start blinking once a second to really annoy everyone in the room, presenter and audience alike. The time is reset when the button cat is pressed. This makes all of the LEDs turn green again.

TimerboxCatButtonCat.jpg

Uno32 Arduino Code

#include <PICxel.h>

#define PIXEL_PIN    2    // Digital IO pin connected to the NeoPixels.
#define BUTTON_PIN   3    // Digital IO pin connected to the Cat.
#define PULLUP_PIN   4    // Digital IO pin connected to pullup=Vcc.
#define LED_PIN     43    // Digital IO pin connected to the single color board LED.

#define SEC_PER_LED_G2Y 60
#define SEC_PER_LED_Y2R 60
 
#define NUM_LEDS 5

//PICxel constructor(uint8_t # of LEDs, uint8_t pin #, color_mode GRB or HSV);
PICxel strip(NUM_LEDS, PIXEL_PIN, GRB);

//int mode, blinkState=0;
//unsigned int mSecTime;
//int ledIdx;

void setup()
 {  
  pinMode(BUTTON_PIN, INPUT);
  pinMode(LED_PIN, OUTPUT);
  pinMode(PULLUP_PIN, OUTPUT);
  digitalWrite(PULLUP_PIN, 1);
  
  strip.begin();
  strip.clear();
  //mode = 0;
  //ledIdx=0;
  
  delay(10);
}

void loop() 
{
unsigned long startTime=0;
int resetTimer=0;

//set all to green.
for(int i = 0; i < NUM_LEDS; i++)
   strip.GRBsetLEDColor(i, 0,255,0);
strip.refreshLEDs();
delay(10);
  
for(int i=0; i< 5; i++)
   {
   strip.refreshLEDs();
   //Start delay(1000*60) replacement with button check
   startTime = millis();
   while(millis() < startTime+(1000*SEC_PER_LED_G2Y))
      {
      if(digitalRead(BUTTON_PIN) == 0)
        {
        resetTimer = 1;
        break;
        }
      }
   if(resetTimer == 1)
     break;   
     
   strip.GRBsetLEDColor(i, 127,127,0);
   strip.refreshLEDs();   
   }
if(resetTimer == 0)
  {   
  for(int i=0; i< 5; i++)
     {
     //Start delay(1000*60) replacement with button check
     startTime = millis();
     while(millis() < startTime+(1000*SEC_PER_LED_Y2R))
      {
      if(digitalRead(BUTTON_PIN) == 0)
        {
        resetTimer = 1;
        break;
        }
      }
     if(resetTimer == 1)
       break;   
     strip.GRBsetLEDColor(i, 255,0,0);
     strip.refreshLEDs();   
     }
  }

if(resetTimer == 0)
  {
  while(1)
    {
    for(int i=0; i< NUM_LEDS; i++)
      strip.GRBsetLEDColor(i, 255,0,0);
    strip.refreshLEDs();
    
    //Start delay(500) replacement with button check
    startTime = millis();
    while(millis() < startTime+500)
      {
      if(digitalRead(BUTTON_PIN) == 0)
        {
        resetTimer = 1;
        break;
        }
      }
    if(resetTimer == 1)
      break;   
    strip.clear();
    strip.refreshLEDs();
    
    //Start delay(500) replacement with button check
    startTime = millis();
    while(millis() < startTime+500)
      {
      if(digitalRead(BUTTON_PIN) == 0)
        {
        resetTimer = 1;
        break;
        }
      }
    if(resetTimer == 1)
      break;   
    }
  }
}