IoT lab
Dependencies: mbed C12832 LM75B
Revision 10:091f48cc6eaf, committed 2017-01-11
- Comitter:
- jw574
- Date:
- Wed Jan 11 06:17:06 2017 +0000
- Parent:
- 9:f85504b3c707
- Commit message:
- Report
Changed in this revision
--- a/LM75B.lib Wed Jun 08 10:36:09 2016 +0000 +++ b/LM75B.lib Wed Jan 11 06:17:06 2017 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/neilt6/code/LM75B/#fc27dc535ea9 +http://mbed.org/users/neilt6/code/LM75B/#7ac462ba84ac
--- a/main.cpp Wed Jun 08 10:36:09 2016 +0000
+++ b/main.cpp Wed Jan 11 06:17:06 2017 +0000
@@ -2,16 +2,129 @@
#include "LM75B.h"
#include "C12832.h"
-// Using Arduino pin notation
+DigitalOut red (LED_RED);
+DigitalOut green(LED_GREEN);
+DigitalOut blue(LED_BLUE);
+DigitalIn up(A2);
+DigitalIn down(A3);
+DigitalIn left(A4);
+DigitalIn right(A5);
+DigitalIn fire(D4);
+AnalogIn pot1 (A0);
+AnalogIn pot2 (A1);
C12832 lcd(D11, D13, D12, D7, D10);
LM75B sensor(D14,D15);
-
+PwmOut spkr(D6);
+void start(void);
+void menu(void);
+int ctrl=3;
int main ()
{
- while (1) {
- lcd.cls();
- lcd.locate(0,3);
- lcd.printf("Temp = %.1f\n", sensor.temp());
- wait(1.0);
+ red = 1;
+ green = 1;
+ blue = 1;
+ lcd.cls();
+ start();
+ menu();
+ while(1) {
+ if (left == 1) {
+ ctrl = 1;
+ }
+ if (right == 1) {
+ ctrl = 2;
+ }
+ if (up == 1) {
+ ctrl = 1;
+ }
+ if (down == 1) {
+ ctrl = 2;
+ }
+ if (fire == 1){
+ ctrl = 0;
+ }
+ switch (ctrl){
+ case 0:
+ menu();
+ break;
+ case 1:
+ while(1) {
+ lcd.cls();
+ lcd.locate(0,3);
+ lcd.printf("Temp = %.1f\n", sensor.temp());
+ float i = 0.0;
+ i = sensor.temp();
+ if (i>28.0) {
+ blue =1;
+ green = 1;
+ red = 0;
+ lcd.locate(0,15);
+ lcd.printf("So Hot!");
+ } else if (i<18.0) {
+ red = 1;
+ green = 1;
+ blue = 0;
+ lcd.locate(0,15);
+ lcd.printf("Really Cold.....");
+ } else {
+ red = 1;
+ blue = 1;
+ green = 0;
+ lcd.locate(0,15);
+ lcd.printf("Comfortable!!!");
+ }
+ wait(1.0);
+ if(fire == 1) {
+ lcd.cls();
+ ctrl = 0;
+ red = 1;
+ green = 1;
+ blue = 1;
+ break;
+ }
+ }
+ break;
+ case 2:
+ while(1) {
+ lcd.cls();
+ lcd.locate(0,3);
+ lcd.printf("Pot 1 = %.2f", (float)pot1);
+ lcd.locate(0,14);
+ lcd.printf("Pot 2 = %.2f", (float)pot2);
+ wait(0.1);
+ spkr.period((float)pot1/(float)pot2);
+ spkr=0.8;
+ wait(0.02);
+ if(fire == 1) {
+ ctrl = 0;
+ spkr = 0;
+ lcd.cls();
+ break;
+ }
+ }
+ break;
+ }
}
}
+void menu(void)
+{
+ lcd.locate(0,3);
+ lcd.printf("welcome to mbed world!");
+}
+
+void start(void)
+{
+ int j=5;
+ while(1) {
+ lcd.locate(0,3);
+ lcd.printf("reboot system please wait");
+ lcd.locate(0,15);
+ lcd.printf("time : %d",j);
+ j--;
+ wait(1.0);
+ if(j==0) {
+ break;
+ }
+ }
+ lcd.cls();
+}
+
--- a/mbed.bld Wed Jun 08 10:36:09 2016 +0000 +++ b/mbed.bld Wed Jan 11 06:17:06 2017 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/6c34061e7c34 \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/99b5ccf27215 \ No newline at end of file