![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Slight modifications to original for different LCD and mbed pin outs
Fork of GT_Tuner by
Diff: main.cpp
- Revision:
- 2:0b7bf57470c4
- Parent:
- 1:ae7d0cf78b3e
--- a/main.cpp Wed Oct 26 02:01:28 2011 +0000 +++ b/main.cpp Fri Dec 16 10:15:01 2016 +0000 @@ -1,13 +1,13 @@ - ////////////////////////////////////////// + ////////////////////////////////////////// // // // Guitar Tuner via Goertzel's Algorithm // // Created by: Andrew Durand // // // ////////////////////////////////////////// - +#include "TextLCD.h" #include "mbed.h" #include "adc.h" -#include "NokiaLCD.h" +//#include "NokiaLCD.h" #include <math.h> #define PI 3.1415 #define SAMPLE_RATE 24000 @@ -15,10 +15,21 @@ DigitalOut led_low(LED1); DigitalOut led_ok(LED2); DigitalOut led_high(LED4); -InterruptIn button1(p12); +InterruptIn button1(p6); //mosi //LCD and Other Random Variables -NokiaLCD lcd(p5, p7, p8, p9, NokiaLCD::LCD6610); // mosi, sclk, cs, rst, type +//NokiaLCD lcd(p5, p7, p8, p9, NokiaLCD::LCD6610); // mosi, sclk, cs, rst, type + +/* This code uses libraries created for 4-bit LCD's based on the HD44780. This +program was designed for a similar product (Winstar's WH1602B 2x16 LC) working +into an Mbed LPC1768. +LCD pins: Pin 1(VSS) to Mbed Gnd, Pin 2(VDD) to Mbed VOUT, Pin 3(Vo- contrast) +to Mbed Gnd, Pin 5(R/W) to Mbed Gnd, Pin 15(A)to Mbed VOUT, Pin 16(B) to +MBed Gnd, Pins 4(RS),20(E) and the 4 data bits (DB4 [11] through to DB7 [14]) +go to the Mbed pins described below: */ + +TextLCD lcd(p10, p12, p15, p16, p29, p30); // rs, e, d4-d7 + int string_select = 0; float high, high1, in_tune, in_tune1, in_tune2, in_tune3, low, low1, note, low_mod, high_mod; @@ -29,7 +40,7 @@ float goertzelFilter(int samples[], float freq, int N) { float s_prev = 0.0; float s_prev2 = 0.0; - float coeff,normalizedfreq,power,s,k; + float coeff,normalizedfreq,power,s; //k was defined here but nolonger needed int i; normalizedfreq = freq / SAMPLE_RATE; coeff = 2*cos(2*PI*normalizedfreq); @@ -60,7 +71,7 @@ button1.rise(&button1_pressed); //Setup LCD - lcd.background(0xF0000F); +// lcd.background(0xF0000F); lcd.cls(); while (1) { @@ -156,16 +167,17 @@ } // Display on the LCD + // lcd.locate(0,1); + // lcd.printf("Guitar Tuner"); + // lcd.locate(0,3); + // lcd.printf("Tuning String: %i", (6-string_select)); + int pintwenty = adc.read(p20); //read pin 20 lcd.locate(0,1); - lcd.printf("::Guitar Tuner::"); - lcd.locate(0,3); - lcd.printf("Tuning String: %i", (6-string_select)); - lcd.locate(0,5); - lcd.printf("%s at %i Hz",key, (int) note); - lcd.locate(5,7); - if (led_ok) lcd.printf("In Tune!"); - else if (led_low) lcd.printf("Too Low "); - else if (led_high) lcd.printf("Too High"); + lcd.printf("%s %iHz %d\n",key, (int) note, pintwenty); + // lcd.locate(0,2); + if (led_ok) lcd.printf("Ok "); + else if (led_low) lcd.printf("Low "); + else if (led_high) lcd.printf("High"); else lcd.printf("~~~~~~~~"); Counter = 0; @@ -173,5 +185,5 @@ } - + } \ No newline at end of file