Uses 2 Potentiometers on the app-board to control red and green LED. Blue LED is controlled by using Up and Down buttons on the joystick. When Joystick is pressed down, the song will be played.
Fork of app-board-RGB by
songs.cpp
- Committer:
- ArthurSemjonov
- Date:
- 2014-02-12
- Revision:
- 1:4a2a53bbc623
File content as of revision 1:4a2a53bbc623:
/* * song.cpp * * Created on: Feb 11, 2014 * Author: Artur Semjonov */ #include "mbed.h" #include "songs.h" PwmOut speaker(p26); DigitalIn off(p14); // middle joystick used to turn off the song Songs::Songs() {} void Songs::songOfMyPeople(float frequency[], float beat[]) { while(1) { //run infinetly unless interupted for (int i=0; i<=8; i++) { speaker.period(1/(2*frequency[i])); // set PWM period speaker=0.5; // set duty cycle wait(0.4*beat[i]); if (off) { speaker = 0; //reset speaker duty cycle wait(2); //delay for inferior humans return; } } speaker = 0; wait(0.25); } }