version one
Dependencies: 4DGL-uLCD-SE SDFileSystem mbed wave_player
Revision 0:82705a2c05d1, committed 2014-03-24
- Comitter:
- Septimus
- Date:
- Mon Mar 24 17:45:38 2014 +0000
- Child:
- 1:f35df38e9b16
- Commit message:
- version one
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/4DGL-uLCD-SE.lib Mon Mar 24 17:45:38 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/4180_1/code/4DGL-uLCD-SE/#e39a44de229a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDFileSystem.lib Mon Mar 24 17:45:38 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/SDFileSystem/#c8f66dc765d4
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Mar 24 17:45:38 2014 +0000 @@ -0,0 +1,83 @@ +#include "mbed.h" +#include "uLCD_4DGL.h" +#include "SDFileSystem.h" +#include "wave_player.h" + +//The section below lists all inputs and outputs for the program. +//pc allows us to read data on the PC should we need to check that correct values are going through. +//LCD allows us to connect to the uLCD display and send commands as needed. +//sd allows us to send commands to the SD card reader on the board. +//DACout is connected to the speaker and outputs audio gathered from the SD Card reader. +//Sonr allows for the MBED to read in data from the EZ-LV Sonar. +//waver allows us to connect to DACout and play audio files as needed. + +Serial pc(USBTX,USBRX); +uLCD_4DGL LCD(p9,p10,p11); +SDFileSystem sd(p5, p6, p7, p12, "sd"); //SD card +AnalogOut DACout(p18); +AnalogIn Sonr(p17); +wave_player waver(&DACout); + +FILE *wave_file; +int trigger=4; +int Cat=0; +float adc, volts, inches; +int feet, in; + + +int main() { + +while(1){ + + pc.printf("%8.2fV %8.2f in\n", volts, inches); + adc = Sonr.read(); // read analog as a float + volts = adc * 3.3; // convert to volts + inches = volts / 0.0064; // 3.3V supply: 6.4mV per inch + + if(inches < 8){ + + if(trigger != 0){ + LCD.cls(); + } + + LCD.media_init(); + LCD.set_sector_address(0x000F, 0x2301); + LCD.display_image(0,0); + wave_file=fopen("/sd/AngryCat.wav","r"); + waver.play(wave_file); + fclose(wave_file); + trigger=0; + } + + + else if(inches >= 8 && inches < 12){ + + if(trigger != 1){ + LCD.cls(); + } + + LCD.media_init(); + LCD.set_sector_address(0x000F, 0x2342); + LCD.display_image(0,0); + wave_file=fopen("/sd/NervousCat.wav","r"); + waver.play(wave_file); + fclose(wave_file); + trigger=1; + } + + else if(inches > 12){ + + if(trigger != 2){ + LCD.cls(); + } + + LCD.media_init(); + LCD.set_sector_address(0x000F, 0x2383); + LCD.display_image(0,0); + wave_file=fopen("/sd/NiceCat.wav","r"); + waver.play(wave_file); + fclose(wave_file); + trigger=2; + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Mar 24 17:45:38 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/8e73be2a2ac1 \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wave_player.lib Mon Mar 24 17:45:38 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/sravet/code/wave_player/#acc3e18e77ad