Show Posts
Pages: [1]
1  Using Arduino / Project Guidance / Countdown Timer Lockbox Dilemna on: December 09, 2012, 10:03:20 pm
Hello fellow Arduino enthusiasts!

I am currently working on a gift for a buddy that is graduating soon. Basically, I would like to make a timed-lock box. Currently, my plan is to used the Doomsday Clock shield from Samurai Circuits along with their countdown library. My goal is to countdown until his day of graduation, in which a buzzer will go off letting him know that he can open his box (maybe adding a servo controlled lock later? tbd). Right now, I just want to get the buzzer working when the count reaches 0.

I've been playing with if statements and for statements to get the buzzer to work, but so far it is saying nay nay to me. As of right now, whenever I add the tone(buzzPin1, 800, 1000) in, it ignores the if or for statement and just does the buzzer while still counting down to 0. Any advice would be greatly appreciated. I have also tried a switch case statement but I (a) dont understand what the site says about them, and (b) dont know if they are even applicable in this case.

Attached is the code and the website that has everything dealing with the libraries and the shield.

Code:
#include <Doomsday.h>

Doomsday doom;
int  buzzPin1 = A1;// This is the pin for the Buzzer
int _Second;
int _Minute;
int i;

void setup ()
{
 
  doom.begin (72); // 72 ms ~~ 14 Hz
  doom.setClock (05, 00, 00, 00, 00, 00);
}

void loop ()
{

  static unsigned int dots = 0;
  dots = (dots << 1) | !(dots & 4);
  doom.secondsTick (-1);
  //doom.printd ("%H:%M:%S", dots);
  doom.printd ("%H%(:%)%M%(:%)%S", dots);
  //doom.printd ("HE:%[L%]LO%(O%)", dots);
  // this will make it beep at 800 Hz for 10 milliseconds
    //tone(buzzPin1, 800, 10);
   
   
    if(_Second >= 1)
   
      noTone (buzzPin1)

    else
   
      tone(buzzPin1, 800, 1000) // this will make it beep at 800 Hz for 10 milliseconds
    //tone(buzzPin1, 800, 1000);
   
   
}


http://www.samuraicircuits.com/MediaWiki/index.php?title=Doomsday_Clock_Shield#Top_Reasons_You_Need_a_Count_Down_Clock

http://www.samuraicircuits.com/merch/11-doomsday-clock-shield-kit.html

thanks guys
2  Using Arduino / Project Guidance / Re: Trouble with our Keypad Code on: November 02, 2012, 01:46:51 am
Sorry, we are very very very new and are attempting to stumble our way through this until we fall flat on our faces with some wisdom.
3  Using Arduino / Project Guidance / Trouble with our Keypad Code on: November 01, 2012, 11:43:54 pm
Hello fellow programmers!
It’s a late night here at CCM, having trouble with our Midterm for our Special Topics Class. Our code is having a lot of syntax problems, and we are having exceptional difficulty making the (##) portion of our assignment, as (#) also funtions as an enter key as well. Here is the official assignment:
Four Digit Key PAD UN-LOCK- CODE
   RED/GREEN LED is Flashing  GREEN……. One flash every two seconds…
   Each time a key is pushed the RED/GREEN LED flashes one time GREEN and is then off… (if another key is not pressed in 5 seconds….Lock the KEYPAD)
   After the correct four digits and the enter key, the RED/GREEN LED  Flashes 4 times and stays on GREEN

Here is what we have so far (very hodge podge coding, brace yourself)


Code:

int i, k, pwcount=0;
char password[] = "1342", entry[10];
int ledGreen = 9;
int ledRed = 10;

void setup()
{
  Serial.begin(9600);
 
 for(i=2; i<=5; i++)
 pinMode(i, INPUT);
  for(i=6; i<=9; i++)
 pinMode(i, OUTPUT);
  pinMode(ledGreen, OUTPUT);
 pinMode(ledRed, OUTPUT);
}

void loop()
{
 
  for(i=6; i<=8; i++){
  reset();
  digitalWrite(i, HIGH);
  if(digitalRead(2)==HIGH && i==6){
    blinker();
    entry[pwcount] = '1';
    pwcount++;
   delay(300);
  Serial.print('1');
  }
  if(digitalRead(3)==HIGH && i==6){
    blinker();
    entry[pwcount] = '4';
    pwcount++;
   delay(300);
  Serial.print('4');
  }
  if(digitalRead(4)==HIGH && i==6){
    blinker();
    entry[pwcount] = '7';
    pwcount++;
   delay(300);
  Serial.print('7');
  } 
   if(digitalRead(5)==HIGH && i==6){
     blinker();
    entry[pwcount] = '*';
    pwcount++;
   delay(300);
  Serial.print('*');
  }
 
   if(digitalRead(2)==HIGH && i==7){
     blinker();
    entry[pwcount] = '2';
    pwcount++;
   delay(300);
  Serial.print('2');
  }
  if(digitalRead(3)==HIGH && i==7){
    blinker();
    entry[pwcount] = '5';
    pwcount++;
   delay(300);
  Serial.print('5');
  }
  if(digitalRead(4)==HIGH && i==7){
    blinker();
    entry[pwcount] = '8';
    pwcount++;
   delay(300);
  Serial.print('8');
  } 
   if(digitalRead(5)==HIGH && i==7){
     blinker();
   entry[pwcount] = '0';
    pwcount++;
   delay(300);
  Serial.print('0');
  }
 
    if(digitalRead(2)==HIGH && i==8){
      blinker();
    entry[pwcount] = '3';
    pwcount++;
   delay(300);
  Serial.print('3');
  }
  if(digitalRead(3)==HIGH && i==8){
    blinker();
   entry[pwcount] = '6';
    pwcount++;
   delay(300);
  Serial.print('6');
  }
  if(digitalRead(4)==HIGH && i==8){
    blinker();
   entry[pwcount] = '9';
    pwcount++;
   delay(300);
  Serial.print('9');
  } 
   if(digitalRead(5)==HIGH && i==8){
    blinker();
   delay(300);
  Serial.println('#');
  pwcount=0;
  for(k=0; k<=4; k++){
   if(k==4){
   Serial.println("Access Granted");
   digitalWrite(ledGreen, HIGH);
   delay(500);
   digitalWrite(ledGreen, LOW);
   delay(500);
   digitalWrite(ledGreen, HIGH);
   delay(500);
   digitalWrite(ledGreen, LOW);
   delay(500);
   digitalWrite(ledGreen, HIGH);
   delay(500);
   digitalWrite(ledGreen, LOW);
   delay(500);
   digitalWrite(ledGreen, HIGH);
   delay(500);
   digitalWrite(ledGreen, LOW);
   delay(500);
   digitalWrite(ledGreen, HIGH);
   break;
   }
   if(password[k] != entry[k]){
     Serial.println("Denied");
     digitalWrite(ledRed, HIGH);
     delay (500);
     digitalWrite(ledRed, LOW);
     delay(500);
     digitalWrite(ledRed, HIGH);
     delay (500);
     digitalWrite(ledRed, LOW);
     delay(500);
     digitalWrite(ledRed, HIGH);
     delay (500);
     digitalWrite(ledRed, LOW);
     delay(500);
     digitalWrite(ledRed, HIGH);
     delay (500);
     digitalWrite(ledRed, LOW);
     delay(500);
     digitalWrite(ledRed, HIGH);
     break;
   }
  }
  for(k=0; k<10; k++)
  entry[k]=0;
  } 
}}

void reset(){
   int j;
   for(j=6; j<=8; j++)
   digitalWrite(j, LOW);
}

void blinker(){
  digitalWrite(ledGreen, HIGH);
  delay(20);
  digitalWrite(ledGreen, LOW);
 
}

Pages: [1]