A program to automatically tune a guitar. Written by Justin Reidhead and Steven Swenson
Dependencies: FFT FrequencyFinder Motor NewTextLCD PinDetect mbed strings
main.cpp
- Committer:
- melangeaddict
- Date:
- 2012-04-15
- Revision:
- 0:d8909ac31fbf
- Child:
- 1:4a82a5178506
File content as of revision 0:d8909ac31fbf:
#include "mbed.h" //Button interrupts InterruptIn start_stop_b(p5); InterruptIn pitch_b(p6); InterruptIn string_b(p7); InterruptIn mode_b(p8); // //AnalogIn AnalogIn guitar(p20); //Motor Controller outputs PwmOut step(p26); DigitalOut direction(p27); DigitalOut motor_enable(p28); //Local File pointer LocalFileSystem local("local"); //Global Variables bool begin=false; //Functions void device_init(){ return;} void start(){ begin=true; return;} void stop(){ return;} void pitch(){ return;} void string(){ return;} void mode(){ return;} int main() { int state=0, next_state=0; start_stop_b.rise(&start);//Assign what functions to call when pitch_b.rise(&pitch); //the interrupt occurs string_b.rise(&string); mode_b.rise(&mode); device_init(); while (1) { state=next_state; switch (state) { case(0)://Waiting for user input if(begin){ next_state=1; } else next_state=0; break; case(1)://Take Sample break; case(2)://Take FFT break; case(3)://Analyze FFT for Peaks break; case(4)://Compare current freq with desired //Determine Hz per step break; case(5)://Motor Direction Calibration break; case(6)://Step Up break; case(7)://Step Down break; default: break; } } }