A program to automatically tune a guitar. Written by Justin Reidhead and Steven Swenson
Dependencies: FFT FrequencyFinder Motor NewTextLCD PinDetect mbed strings
Diff: main.cpp
- Revision:
- 6:46fb12f6ace1
- Parent:
- 5:c0fd99f07536
- Child:
- 7:057bcd99a3f8
--- a/main.cpp Tue Apr 17 19:46:33 2012 +0000 +++ b/main.cpp Thu Apr 19 20:31:42 2012 +0000 @@ -17,10 +17,16 @@ //DigitalOut led1(LED1);//For diagnostic purposes //DigitalOut led2(LED2); -TextLCD lcd(p10,p9,p8,p7,p6,p5);//Our method of communication with LCD screen (rs e d4 d5 d6 d7) -Motor motor(p19,p20,p21);//Setup for the motor (enable, direction, step) +TextLCD lcd(p5,p6,p7,p8,p9,p10);//Our method of communication with LCD screen (rs e d4 d5 d6 d7) +Motor motor(p24,p20,p21);//Setup for the motor (enable, direction, step) FrequencyFinder guitar(p18);//Interface to get data from guitar (input pin) + +DigitalOut ledBlue(p25); +DigitalOut ledGreen(p23); +DigitalOut ledRed(p24); + + short selected_string;//Holds on to the selected string bool current_mode;//Tuning mode or winding mode bool start_tuning;//Bool to tell whether to start the tuning process or not @@ -56,12 +62,15 @@ void output_menu(); void motor_calibration(); bool check_threshold(float); +void LED_initialize(); +void set_LED(int led, int value); //************************************************* //*********************main************************ int main() { + lcd.cls();//Clear the LCD lcd.printf("Perfect\n Pitch");//Modify to whatever we want to name this thing - + LED_initialize(); wait(.5); device_init();//Setup buttons and set global variables @@ -385,3 +394,69 @@ } else return true; } + + + +void LED_initialize() { + float wait_time=0.3; + ledBlue=1;//red + ledGreen=1; + ledRed=0; + wait(wait_time); + ledRed=1;//green + ledGreen=0; + wait(wait_time); + ledGreen=1; + ledBlue=0;//blue + wait(wait_time); + + for (int a=0; a<5; a++) { + ledRed=0;//all + ledGreen=0; + ledBlue=0; + wait(wait_time); + ledRed=1; + ledGreen=1; + ledBlue=1; + wait(wait_time); + + } + ledBlue=0; + + + ledRed=1;//blue + ledGreen=1; + + return; + +} + + +void set_LED(int led, int value) { + //ledBlue=1; + //ledRed=2; + //ledGreen=3; + //value must be an int: 0 or 1 + if(value!=0) + + switch (led) { + case(1): + ledBlue=value; + break; + + case(2): + ledRed=value; + break; + + case(3): + ledGreen=value; + break; + + default: + break; + + } + + return; + +} \ No newline at end of file