Shahariar
Published © CC BY-SA

Countdown Voice Timer & Fire Starter

A programmable countdown timer with loud voice countdown and trigger for dangerous experiments like starting fireworks

BeginnerFull instructions provided6 hours2,883
Countdown Voice Timer & Fire Starter

Things used in this project

Hardware components

Beetle - The Smallest Arduino
DFRobot Beetle - The Smallest Arduino
×1
Monochrome 0.91”128x32 I2C OLED Display with Chip Pad
DFRobot Monochrome 0.91”128x32 I2C OLED Display with Chip Pad
×1
DFRobot DF Voice Rec/Playback Module
×1
DFRobot Enclosed Speaker
×1
DFRobot Mini Push Buttons
×1
DFRobot Nylon Cable Ties
×1
DFRobot Proto Board
×1
DFRobot USB A to C Cable
×1
Arduino Leonardo
Arduino Leonardo
×1
Red Hot Wires
×1

Software apps and online services

Arduino IDE
Arduino IDE
Text to Speech Reader Online
Audacity - Audio Recording and Editing App

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free

Story

Read more

Schematics

Schematic

Relay and Fire Starter Circuit

Code

code

C/C++
Code for Beetle/Arduino Leonardo board
#include "U8glib.h"
#include <DFRobot_DF1101S.h>
#include <SoftwareSerial.h>

SoftwareSerial df1101sSerial(10, 11);          // RX = 10  TX = 11
U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE);   // SCL = 2  SDA = 3

DFRobot_DF1101S df1101s;

#define BUTTON_DEC    A2
#define BUTTON_INC     1
#define BUTTON_SEL    A0

#define OUTPUT_PIN1   0
#define OUTPUT_PIN2   A1
#define OUTPUT_PIN3   9

#define BLUE_LED      13

/////////////////////////
// FILE0999.MP3 says "FIRE"
#define FIRE      999
#define THOUSAND  103
#define MILLION   106
#define BILLION   109
#define tRILLION  112

// record more mp3 and add more defines like this
// if device needs to say something through speaker

//////////////////////////////////////////////////


int number_index = 3;
int volume = 10;
long last_millis;

void setup(void)
{
 
 u8g.setRot90();        // change oled display orientation

 // set GPIOs for buttons and LED
 
 pinMode(BUTTON_DEC, INPUT_PULLUP);
 pinMode(BUTTON_INC, INPUT_PULLUP);
 pinMode(BUTTON_SEL, INPUT_PULLUP);
 pinMode(BLUE_LED, OUTPUT);

 //  Output pins for controlling something
 pinMode(OUTPUT_PIN1, OUTPUT); digitalWrite(OUTPUT_PIN1,LOW);
 pinMode(OUTPUT_PIN2, OUTPUT); digitalWrite(OUTPUT_PIN2,LOW);
 
 // welcome message  
 update_display_message_0();
 delay(500);

 // init soft serial to communicate with voice playback moduel
 
  df1101sSerial.begin(115200);
  delay(100);
  while(!df1101s.begin(df1101sSerial))
  {
  update_display_message_1();  
  df1101s.setPrompt(false);  
  }
  
  //Set initial volume to 10
  df1101s.setVol(volume);

  // set playback mode
  df1101s.switchFunction(df1101s.MUSIC);

  // fast blink LED on pin 13
  for(int i = 0; i<10; i++)
  {debounce_blinky();}

 
 
 // adjust volume with buttons
 // BUTTON_SEL for selecting shown value
 // BUTTON_INC for increasing shown value
 // BUTTON_DEC for decreasing shown value
 
  while(digitalRead(BUTTON_SEL))
  {
    if(!digitalRead(BUTTON_DEC))
    {
      volume--;
      debounce_blinky();
    }
    if(!digitalRead(BUTTON_INC))
    {
      volume++;
      debounce_blinky();
    }
    if (volume<10)   {volume = 10;}
    if (volume>30)   {volume = 30;}
    
    df1101s.setVol(volume);     // set volume for Spk
    update_display_message_2(); // update OLED
  }

for(int i = 0; i<10; i++)
{debounce_blinky();}

// set mp3 playback as single cycle
df1101s.setPlayMode(df1101s.SINGLECYCLE);  
 
}

void loop()
{

set_count_down_timer();    

while(number_index>=0)
{
df1101s.playSpecFile(number_index);
update_display_message_4();  
last_millis =millis();
while(millis()<last_millis+1000)
{}
number_index--;
}

// control fire starter circuit
trigger_event();

 
} // end of loop

///////////////////////////////////
///control and display functions///
///////////////////////////////////

void update_display_message_0(void)
{    
  u8g.firstPage();  
  do {
     u8g.setFont(u8g_font_6x12); 
     u8g.drawStr( 0, 10, "This");
     u8g.drawStr( 0, 25, "is a");
     u8g.drawStr( 0, 40, "voice");
     u8g.drawStr( 0, 55, "count");
     u8g.drawStr( 0, 70, "down");
     u8g.drawStr( 0, 85, "Timer");
     
  } while( u8g.nextPage() );
}



void update_display_message_1(void)
{    
  u8g.firstPage();  
  do {
     u8g.setFont(u8g_font_6x12); 
     u8g.drawStr( 0, 10, "Please");
     u8g.drawStr( 0, 25, "check");
     u8g.drawStr( 0, 40, "if Ckt");
     u8g.drawStr( 0, 55, "Wiring");
     u8g.drawStr( 0, 70, "is OK !");
     u8g.drawStr( 0, 85, "or Not");
  } while( u8g.nextPage() );
}

void update_display_message_2(void)
{    
  
  u8g.firstPage();  
  do {
   u8g.setFont(u8g_font_7x13);  
   u8g.drawStr( 4, 40, "Adj");
   u8g.drawStr( 4, 55, "VOL:");   
   u8g.drawStr( 4, 110, "-  +");
   u8g.setFont(u8g_font_10x20);  
   u8g.setPrintPos(8, 90);u8g.print(volume);
 
  } while( u8g.nextPage() );



}


void update_display_message_3(void)
{
    u8g.firstPage();  
  do {
    u8g.setFont(u8g_font_7x13); 
    u8g.drawStr( 0, 10, "Set ");
    u8g.drawStr( 0, 25, "Count");
    u8g.drawStr( 0, 40, "Down");
    u8g.drawStr( 0, 55, "Timer");
    u8g.drawStr( 4, 110, "-  +");
    u8g.setFont(u8g_font_10x20); 
    u8g.setPrintPos(8,90 );u8g.print(number_index);
     
  } while( u8g.nextPage() );
delay(10);

}

void update_display_message_4(void)
{
    u8g.firstPage();  
  do {
    u8g.setFont(u8g_font_7x13); 
    u8g.drawStr( 0, 10, "Count");
    u8g.drawStr( 0, 25, "Down");
    u8g.drawStr( 0, 40, "Time");
    u8g.drawStr( 0, 55, "Left");
    
    u8g.setFont(u8g_font_10x20); 
    u8g.setPrintPos(5,90 );u8g.print(number_index);
     
  } while( u8g.nextPage() );
delay(10);

}

void update_display_message_5(void)
{
    u8g.firstPage();  
  do {
    u8g.setFont(u8g_font_6x12); 
    u8g.drawStr( 0, 10, "Trigg");
    u8g.drawStr( 0, 25, "Active");
    u8g.drawStr( 0, 40, "NOW!!");
    u8g.setFont(u8g_font_7x13); 
    u8g.drawStr( 0, 80, "&&&&");    
    u8g.drawStr( 0, 95, "FIRE");
    u8g.drawStr( 0, 105, "FIRE");
     
  } while( u8g.nextPage() );
delay(10);

}


void debounce_blinky(void)
{
  digitalWrite(BLUE_LED,HIGH);
  delay(25);  
  digitalWrite(BLUE_LED,LOW);
  delay(25);

}



void set_count_down_timer(void)
{
  while(digitalRead(BUTTON_SEL))
  {
    if(!digitalRead(BUTTON_DEC))
    {
      number_index--;
      debounce_blinky();
    }
    if(!digitalRead(BUTTON_INC))
    {
      number_index++;
      debounce_blinky();
    }
    if (number_index<0)   {number_index = 0;}
    if (number_index>100) {number_index = 100;}
    
    update_display_message_3();
  }
  
}

void trigger_event (void)
{
  digitalWrite(OUTPUT_PIN1,HIGH);
  delay(300);
  update_display_message_5();
  df1101s.playSpecFile(FIRE);
  digitalWrite(OUTPUT_PIN1,LOW);
  delay(2000);
  digitalWrite(OUTPUT_PIN2,HIGH);
  delay(300);
  digitalWrite(OUTPUT_PIN2,LOW);
  delay(200);
}

DF_REC folder

C Header File
Download, Unzip and copy the entire folder to Voice Recorder/Playback Module
No preview (download only).

code for serialover control

C/C++
For the PSoC6 offllne alexa
#include "U8glib.h"
#include <DFRobot_DF1101S.h>
#include <SoftwareSerial.h>

SoftwareSerial df1101sSerial(10, 11);          // RX = 10  TX = 11
SoftwareSerial PSoC6Serial(9, A1);          // RX = 9  TX = A1

U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE);   // SCL = 2  SDA = 3

DFRobot_DF1101S df1101s;

#define BUTTON_DEC    A2
//#define BUTTON_INC     1 // Button disabled for serial port purpose (won't worry !)
#define BUTTON_SEL    A0

//#define OUTPUT_PIN1   0 // Output disabled for serial port usage 
#define OUTPUT_PIN2   A1
#define OUTPUT_PIN3   9

#define BLUE_LED      13

/////////////////////////
// FILE0999.MP3 says "FIRE"
#define FIRE      999
#define THOUSAND  103
#define MILLION   106
#define BILLION   109
#define tRILLION  112

// record more mp3 and add more defines like this
// if device needs to say something through speaker

//////////////////////////////////////////////////


int number_index = 3;
int volume = 10;
long last_millis;

void setup(void)
{
 
 u8g.setRot90();        // change oled display orientation

 // set GPIOs for buttons and LED
 
 pinMode(BUTTON_DEC, INPUT_PULLUP);
 //pinMode(BUTTON_INC, INPUT_PULLUP);
 pinMode(BUTTON_SEL, INPUT_PULLUP);
 pinMode(BLUE_LED, OUTPUT);

 //  Output pins for controlling something
 //pinMode(OUTPUT_PIN1, OUTPUT); digitalWrite(OUTPUT_PIN1,LOW);
 pinMode(OUTPUT_PIN2, OUTPUT); digitalWrite(OUTPUT_PIN2,LOW);
 
 // welcome message  
 update_display_message_0();
 delay(500);

 // init soft serial to communicate with voice playback moduel
 
  df1101sSerial.begin(115200);
  delay(100);
  while(!df1101s.begin(df1101sSerial))
  {
  update_display_message_1();  
  df1101s.setPrompt(false);  
  }

  //Set initial volume to 10
  df1101s.setVol(volume);

  // set playback mode
  df1101s.switchFunction(df1101s.MUSIC);

  // fast blink LED on pin 13
  for(int i = 0; i<10; i++)
  {debounce_blinky();}

   
  // init hard serial
  
  PSoC6Serial.begin(115200);
   
 
 // adjust volume with buttons
 // BUTTON_SEL for selecting shown value
 // BUTTON_INC for increasing shown value
 // BUTTON_DEC for decreasing shown value
 

for(int i = 0; i<10; i++)
{debounce_blinky();}

// set mp3 playback as single cycle
df1101s.setPlayMode(df1101s.SINGLECYCLE);  
 
}

void loop()
{


while(true)
{
if (PSoC6Serial.available())
{
  char incoming_cmd[3]= "000";
  PSoC6Serial.readBytes(incoming_cmd, 3);
  int playback_index = atoi(incoming_cmd);
  df1101s.playSpecFile(incoming_cmd);  
//  Serial.print(incoming_cmd);
}


}

// control fire starter circuit
//trigger_event();

 
} // end of loop

///////////////////////////////////
///control and display functions///
///////////////////////////////////

void update_display_message_0(void)
{    
  u8g.firstPage();  
  do {
     u8g.setFont(u8g_font_6x12); 
     u8g.drawStr( 0, 10, "This");
     u8g.drawStr( 0, 25, "is a");
     u8g.drawStr( 0, 40, "Stove");
     u8g.drawStr( 0, 55, "that");
     u8g.drawStr( 0, 70, "can");
     u8g.drawStr( 0, 85, "Talk");
     
  } while( u8g.nextPage() );
}



void update_display_message_1(void)
{    
  u8g.firstPage();  
  do {
     u8g.setFont(u8g_font_6x12); 
     u8g.drawStr( 0, 10, "Please");
     u8g.drawStr( 0, 25, "check");
     u8g.drawStr( 0, 40, "if Ckt");
     u8g.drawStr( 0, 55, "Wiring");
     u8g.drawStr( 0, 70, "is OK !");
     u8g.drawStr( 0, 85, "or Not");
  } while( u8g.nextPage() );
}

void update_display_message_2(void)
{    
  
  u8g.firstPage();  
  do {
   u8g.setFont(u8g_font_7x13);  
   u8g.drawStr( 4, 40, "Adj");
   u8g.drawStr( 4, 55, "VOL:");   
   u8g.drawStr( 4, 110, "-  +");
   u8g.setFont(u8g_font_10x20);  
   u8g.setPrintPos(8, 90);u8g.print(volume);
 
  } while( u8g.nextPage() );



}


void update_display_message_3(void)
{
    u8g.firstPage();  
  do {
    u8g.setFont(u8g_font_7x13); 
    u8g.drawStr( 0, 10, "Set ");
    u8g.drawStr( 0, 25, "Count");
    u8g.drawStr( 0, 40, "Down");
    u8g.drawStr( 0, 55, "Timer");
    u8g.drawStr( 4, 110, "-  +");
    u8g.setFont(u8g_font_10x20); 
    u8g.setPrintPos(8,90 );u8g.print(number_index);
     
  } while( u8g.nextPage() );
delay(10);

}

void update_display_message_4(void)
{
    u8g.firstPage();  
  do {
    u8g.setFont(u8g_font_7x13); 
    u8g.drawStr( 0, 10, "Count");
    u8g.drawStr( 0, 25, "Down");
    u8g.drawStr( 0, 40, "Time");
    u8g.drawStr( 0, 55, "Left");
    
    u8g.setFont(u8g_font_10x20); 
    u8g.setPrintPos(5,90 );u8g.print(number_index);
     
  } while( u8g.nextPage() );
delay(10);

}

void update_display_message_5(void)
{
    u8g.firstPage();  
  do {
    u8g.setFont(u8g_font_6x12); 
    u8g.drawStr( 0, 10, "Trigg");
    u8g.drawStr( 0, 25, "Active");
    u8g.drawStr( 0, 40, "NOW!!");
    u8g.setFont(u8g_font_7x13); 
    u8g.drawStr( 0, 80, "&&&&");    
    u8g.drawStr( 0, 95, "FIRE");
    u8g.drawStr( 0, 105, "FIRE");
     
  } while( u8g.nextPage() );
delay(10);

}


void debounce_blinky(void)
{
  digitalWrite(BLUE_LED,HIGH);
  delay(25);  
  digitalWrite(BLUE_LED,LOW);
  delay(25);

}

Credits

Shahariar

Shahariar

74 projects • 264 followers
"What Kills a 'Great life' is a 'Good Life', which is Living a Life Inside While Loop"

Comments