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.

Dependencies:   mbed

Fork of app-board-RGB by Chris Styles

Committer:
ArthurSemjonov
Date:
Wed Feb 12 21:07:58 2014 +0000
Revision:
1:4a2a53bbc623
Parent:
0:f86c572491c3
Change the name of the project;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
chris 0:f86c572491c3 1 #include "mbed.h"
ArthurSemjonov 1:4a2a53bbc623 2 #include "songs.h"
ArthurSemjonov 1:4a2a53bbc623 3
chris 0:f86c572491c3 4
ArthurSemjonov 1:4a2a53bbc623 5 /*******LED brightness value range from 0 to 1***********/
ArthurSemjonov 1:4a2a53bbc623 6 PwmOut r (p23); //red
ArthurSemjonov 1:4a2a53bbc623 7 PwmOut g (p24); //greeb
ArthurSemjonov 1:4a2a53bbc623 8 PwmOut b (p25); //blue
ArthurSemjonov 1:4a2a53bbc623 9 /********************************************************/
ArthurSemjonov 1:4a2a53bbc623 10 AnalogIn p1(p19); //Potentiometers left (red)
ArthurSemjonov 1:4a2a53bbc623 11 AnalogIn p2(p20); //Potentiometers right (green)
ArthurSemjonov 1:4a2a53bbc623 12 DigitalIn joyUP(p15); //Adds blue button
ArthurSemjonov 1:4a2a53bbc623 13 DigitalIn joyDOWN(p12); //Subtracts blue button
ArthurSemjonov 1:4a2a53bbc623 14 DigitalIn joyMID(p14); //Play the song button
ArthurSemjonov 1:4a2a53bbc623 15
ArthurSemjonov 1:4a2a53bbc623 16 Songs play; //song object
ArthurSemjonov 1:4a2a53bbc623 17
ArthurSemjonov 1:4a2a53bbc623 18 /*************************************I Am the Doctor***********************************/
ArthurSemjonov 1:4a2a53bbc623 19 float frequency[]= {146.83, 164.81, 174.61, 196, 174.61 ,164.81, 146.83, 164.81, 146.83};
ArthurSemjonov 1:4a2a53bbc623 20 float beat[]= {.9,.9,.9,0.5,.9,.9,.9,0.5,0.5, 0.5};
ArthurSemjonov 1:4a2a53bbc623 21 /***************************************************************************************/
chris 0:f86c572491c3 22
chris 0:f86c572491c3 23 int main()
chris 0:f86c572491c3 24 {
chris 0:f86c572491c3 25 while(1) {
ArthurSemjonov 1:4a2a53bbc623 26 r = p1; //read left potentiometer and set red light
ArthurSemjonov 1:4a2a53bbc623 27 g = p2; //read right potentiometer and set green light
ArthurSemjonov 1:4a2a53bbc623 28 if (joyUP) {
ArthurSemjonov 1:4a2a53bbc623 29 b = (b>0) ? b-0.01: b; //if blue > 0, then subtract 0.01 from brightness value
ArthurSemjonov 1:4a2a53bbc623 30 wait(0.01);
ArthurSemjonov 1:4a2a53bbc623 31 } else if (joyDOWN) {
ArthurSemjonov 1:4a2a53bbc623 32 b = (b<1) ? b+0.01: b; //if blue < 1, then add 0.01 to brightness value
ArthurSemjonov 1:4a2a53bbc623 33 wait(0.01);
ArthurSemjonov 1:4a2a53bbc623 34 } else if (joyMID) {
ArthurSemjonov 1:4a2a53bbc623 35 play.songOfMyPeople(frequency, beat); //play the song
ArthurSemjonov 1:4a2a53bbc623 36 wait(0.01);
chris 0:f86c572491c3 37 }
ArthurSemjonov 1:4a2a53bbc623 38 wait (0.01);
chris 0:f86c572491c3 39 }
chris 0:f86c572491c3 40 }