Power Grid Board Game Timer. Acts like a chess timer for 3-6 people. Uses an ADXL accelerometer to pause the timer and change players. Uses an LCD screen to prompt the players for input, read that input, and change between rounds.

Dependencies:   DmTouch_UniGraphic UniGraphic-forLdelaney17FinalProject mbed

Committer:
ldelaney17
Date:
Wed Jan 25 10:03:52 2017 +0000
Revision:
4:e14c199c2466
everything except the sound works

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ldelaney17 4:e14c199c2466 1 #include "Song.h"
ldelaney17 4:e14c199c2466 2
ldelaney17 4:e14c199c2466 3 void mute(){
ldelaney17 4:e14c199c2466 4 note_duration.detach();
ldelaney17 4:e14c199c2466 5 myBuzzer = 0;
ldelaney17 4:e14c199c2466 6 }
ldelaney17 4:e14c199c2466 7
ldelaney17 4:e14c199c2466 8 void Song::play(){
ldelaney17 4:e14c199c2466 9 if (place_in_song < song_length){
ldelaney17 4:e14c199c2466 10 set_note(place_in_song);
ldelaney17 4:e14c199c2466 11 note_duration.attach(this, &Song::play, beat_length*beats[place_in_song]);
ldelaney17 4:e14c199c2466 12 place_in_song++;
ldelaney17 4:e14c199c2466 13 }
ldelaney17 4:e14c199c2466 14 else{
ldelaney17 4:e14c199c2466 15 mute();
ldelaney17 4:e14c199c2466 16 place_in_song = 0;
ldelaney17 4:e14c199c2466 17 }
ldelaney17 4:e14c199c2466 18 }
ldelaney17 4:e14c199c2466 19
ldelaney17 4:e14c199c2466 20 void Song::set_note(int index){
ldelaney17 4:e14c199c2466 21 myBuzzer.period(1/(2*freqs[index]));
ldelaney17 4:e14c199c2466 22 myBuzzer = 0.5;
ldelaney17 4:e14c199c2466 23 }
ldelaney17 4:e14c199c2466 24
ldelaney17 4:e14c199c2466 25 void Song::set_tempo(int tempo){
ldelaney17 4:e14c199c2466 26 beat_length = 60.0/tempo;
ldelaney17 4:e14c199c2466 27 }