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:
- 0:d8909ac31fbf
- Child:
- 1:4a82a5178506
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Apr 15 00:20:28 2012 +0000 @@ -0,0 +1,92 @@ +#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; + } + + } +} + +