I am building my own variation of a project found here:
It includes this library for tones:
http://arduino-tone.googlecode.com/files/Tone-V0004.zip
I got rid of the switch for selecting time and alarm setting and replaced them with separate buttons.
I also removed the capacitive switch for the snooze button and replaced it with a physical button.
Due to the original author writing it in tabs, the code will be in several posts
Here is my modified code:
/*
==========Arduino Binary Alarm Clock==========
| Author: Martin Forsgren |
| Date: 15-11-2009 |
==============================================
*/
#include <CapSense.h> // library for touchsensors
#include <Tone.h> // library for soundgeneration
#define DEBUG 0 // set to 1 to get debugging output via serial.
// Display pins:
int hour_pins[] = {18, 17, 16, 15, 14}; // hour pins are pins 14 to 18
int minute_pins[] = {13, 12, 11, 10, 9, 8}; // minute pins are 8 to 13
// the values are in falling order because I connected the pins that way by accident
// Button pins:
int hour_button_pin = 6;
int minute_button_pin = 5;
int setTime_button_pin = 7;
int setAlarm_button_pin = 4;
int snooze_button = 3;
// Sound:
int speaker_pin = 19;
Tone tone_maker;
// Button states:
int hour_button_state;
int minute_button_state;
int setTime_button_state;
int setAlarm_button_state;
int snooze_button_state;
// Clock variables, that stores the current time:
int seconds = 0;
int minutes = 10;
int hours = 10;
// hours_p and minutes_p are pointers that are used to decide:
// - if the ordinary time or the alarm time shoud be displayed
// - if the time or the alarm time should be changed when the buttons are pressed
int * hours_p = &hours; // points to hours or alarm_hours depending
// on the setting_switch_state
int * minutes_p = &minutes; // points to minutes or alarm_minutes depending
// on the setting_switch_state
// ALARM VARIABLES:
boolean alarm_on = false;
boolean signal_on = false;
boolean snooze_on = false;
// alarm time:
int alarm_hours = 20;
int alarm_minutes = 20;
// time when snooze period should end:
int snooze_off_hours;
int snooze_off_minutes;
int debug_print_counter = 0;
void setup()
{
// set all six minute pins to output:
for(int i = 0; i < 7; i++)
{
pinMode(minute_pins[i], OUTPUT);
}
// set all five hour pins to output:
for(int i = 0; i < 6; i++)
{
pinMode(hour_pins[i], OUTPUT);
}
// set the button pins to input:
pinMode(hour_button_pin, INPUT);
pinMode(minute_button_pin, INPUT);
pinMode(setTime_button_pin, INPUT);
pinMode(setAlarm_button_pin, INPUT);
// activate the internal pullup resistors:
digitalWrite(hour_button_pin, HIGH);
digitalWrite(minute_button_pin, HIGH);
digitalWrite(setTime_button_pin, HIGH);
digitalWrite(setAlarm_button_pin, HIGH);
digitalWrite(snooze_button, HIGH);
//output sound to the speaker_pin:
tone_maker.begin(speaker_pin);
}
void loop()
{
clock(); // keep track of time, i.e. update hours,
// minutes and seconds variables as needed.
display(); // display the time, or the alarm time, depending on the state of the settings switch.
alarm(); // checks if it's time for the alarm to start.
update_buttons_state(); // checks if the buttons and touch sensor states has changed
//update_buttons_state_with_debounce();
buttons(); // does what the buttons should do
}
And here are my error codes:
C:\Users\tech\Documents\Arduino\libraries\Tone\Tone.cpp: In member function 'void Tone::begin(uint8_t)':
C:\Users\tech\Documents\Arduino\libraries\Tone\Tone.cpp:125: error: 'bitWrite' was not declared in this scope
C:\Users\tech\Documents\Arduino\libraries\Tone\Tone.cpp:127: error: 'digitalPinToPort' was not declared in this scope
C:\Users\tech\Documents\Arduino\libraries\Tone\Tone.cpp:127: error: 'portOutputRegister' was not declared in this scope
C:\Users\tech\Documents\Arduino\libraries\Tone\Tone.cpp:128: error: 'digitalPinToBitMask' was not declared in this scope
C:\Users\tech\Documents\Arduino\libraries\Tone\Tone.cpp: In member function 'void Tone::play(int, long unsigned int)':
C:\Users\tech\Documents\Arduino\libraries\Tone\Tone.cpp:201: error: 'OUTPUT' was not declared in this scope
C:\Users\tech\Documents\Arduino\libraries\Tone\Tone.cpp:201: error: 'pinMode' was not declared in this scope
C:\Users\tech\Documents\Arduino\libraries\Tone\Tone.cpp:284: error: 'bitWrite' was not declared in this scope
C:\Users\tech\Documents\Arduino\libraries\Tone\Tone.cpp: In member function 'void Tone::stop()':
C:\Users\tech\Documents\Arduino\libraries\Tone\Tone.cpp:359: error: 'digitalWrite' was not declared in this scope
Other than changing the pin assignments, I didn't make any changes to the code and I can't figure out what these error codes are referring to.