Liam Grazier
/
0NicksCoursework-lg
diajzifsajoifajsoifaj
Fork of ELEC350-CWTEMPLATE-2017 by
main.cpp
- Committer:
- liam_grazier
- Date:
- 2018-01-05
- Revision:
- 6:f0601ebd2423
- Parent:
- 5:9b4844128e09
- Child:
- 7:dd303488e55d
File content as of revision 6:f0601ebd2423:
#include "components.hpp" #include "SDBlockDevice.h" #include "FATFileSystem.h" //#include "Networkbits.hpp" #include "mbed.h" #include "lglcd.h" #include "stdio.h" // This is a very short demo that demonstrates all the hardware used in the coursework. // You will need a network connection set up (covered elsewhere). The host PC should have the address 10.0.0.1 //Threads Thread nwrkThread; int main(){ lglcd mylcd(D7,D6,D5,D4,D3,D2); mylcd.clear(); while(true){ double temp = sensor.getTemperature(); double pressure = sensor.getPressure(); double lightin = adcIn; char TEM[6]; char PRE[5]; sprintf(TEM,"%.2f", temp); sprintf(PRE,"%.2f", pressure); printf(TEM); printf(PRE); mylcd.setline(1,1); mylcd.write("P:"); mylcd.write(PRE); mylcd.setline(1,10); mylcd.write("T:"); mylcd.write(TEM); mylcd.setline(2,1); mylcd.write("L:"); if(lightin > 0.8 && lightin < 0.9) { mylcd.setline(2,4); mylcd.write(" "); mylcd.setline(2,4); mylcd.write("|||||||||"); } else if(lightin > 0.51 && lightin < 0.9) { mylcd.setline(2,4); mylcd.write(" "); mylcd.setline(2,4); mylcd.write("|||||"); } else if(lightin > 0.4 && lightin < 0.5) { mylcd.setline(2,4); mylcd.write(" "); mylcd.setline(2,4); mylcd.write("|||"); } else if(lightin > 0.2 && lightin < 0.39) { mylcd.setline(2,4); mylcd.write(" "); mylcd.setline(2,4); mylcd.write("LOW"); } else if(lightin < 0.19) { mylcd.setline(2,4); mylcd.write(" "); mylcd.setline(2,4); mylcd.write("disconnected"); } //mylcd.write(light); //printf(adcIn); wait(0.4); } //Flash to indicate goodness }