Hey there. I'm new to the forum and new to Arduino programming so I appreciate any help anyone can offer! I've written a simple sketch that is a countdown timer with a segment counter. The idea is that when the timer reaches zero, a buzzer sounds, the segment timer would increment by 1 and the timer would restart. I've gotten the coding for the timer and buzzer working and now trying to just add the segment counter piece. I've added what I believe is the correct coding but keep receiving the following error:
Arduino: 1.8.8 (Mac OS X), Board: "Arduino/Genuino Uno"
Countdown_Timer:26:25: error: expected unqualified-id before ';' token
int period = startperiod;
^
/Users/rickc/Documents/Arduino/Countdown_Timer/Countdown_Timer.ino: In function 'void loop()':
Countdown_Timer:56:42: error: expected unqualified-id before ')' token
matrix2.writeDigitNum(0, (startperiod));
^
Multiple libraries were found for "Adafruit_GFX.h"
Used: /Users/rickc/Documents/Arduino/libraries/Adafruit_GFX
Not used: /Users/rickc/Documents/Arduino/libraries/Adafruit-GFX-Library-master
exit status 1
expected unqualified-id before ';' token
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Here is the code:
#include <Wire.h>
#include "Adafruit_GFX.h"
#include "Adafruit_LEDBackpack.h"
Adafruit_7segment matrix1 = Adafruit_7segment();
Adafruit_7segment matrix2 = Adafruit_7segment();
unsigned long previousSecondMillis = 0UL;
long oneSecond = 1000UL; // milliseconds per second
const int buzzer = 9; //buzzer to arduino pin 9
#define startMinute 3 // Modify these defines to
#define startSecond 00 // change the timer interval
#define startperiod 1 . // Modify to change the start segment number
int period = startperiod;
int minutes = startMinute;
int seconds = startSecond;
void setup()
{
matrix1.begin(0x70);
matrix2.begin(0x72);
pinMode(buzzer, OUTPUT); // Set buzzer - pin 9 as an output
}
void loop() {
boolean drawDots = true;
// --------- Run this every second ------------------
if (millis() - previousSecondMillis >= oneSecond) {
// } else {
matrix1.writeDigitNum(0, (minutes / 10));
matrix1.writeDigitNum(1, (minutes % 10));
matrix1.drawColon(drawDots);
matrix1.writeDigitNum(3, (seconds / 10));
matrix1.writeDigitNum(4, (seconds % 10));
matrix1.writeDisplay();
matrix2.writeDigitNum(0, (startperiod));
if (seconds-- == 0) {
if (minutes == 0) {
minutes = startMinute;
seconds = startSecond;
tone(buzzer, 1000); // Send 500KHz sound signal...
delay(1000); // ...for 1 sec
noTone(buzzer); // Stop sound...
//delay(1000); // ...for 1sec
//delay(1000);
} else {
//tone(buzzer, 500); // Send 500KHz sound signal...
//delay(1000); // ...for 1 sec
//noTone(buzzer); // Stop sound...
minutes -= 1;
seconds = 59;
}
}
previousSecondMillis += oneSecond;
}
}
Right now, I'm just displaying the counter from it's starting position as I haven't yet figured out the coding to increment the counter.
Any help is appreciated!
Rick