App shield board demo

Dependencies:   C12832_lcd LM75B MMA7660 mbed

Fork of app-board-demo by kinlok chan

Committer:
KinLok
Date:
Tue Jul 30 02:47:21 2013 +0000
Revision:
4:dac7e60ec354
Parent:
3:4d612f16ad84
Child:
5:de9f1d051a3d
rs-app-board-demo

Who changed what in which revision?

UserRevisionLine numberNew contents of line
okano 0:ce7a8546502b 1 #include "mbed.h"
chris 2:9e757151de9b 2 #include "LM75B.h"
chris 2:9e757151de9b 3 #include "C12832_lcd.h"
okano 0:ce7a8546502b 4
KinLok 4:dac7e60ec354 5 PwmOut r (p23);
KinLok 4:dac7e60ec354 6 PwmOut g (p24);
KinLok 4:dac7e60ec354 7 PwmOut b (p25);
KinLok 4:dac7e60ec354 8
chris 2:9e757151de9b 9 C12832_LCD lcd;
chris 2:9e757151de9b 10 LM75B tmp(p28,p27);
okano 0:ce7a8546502b 11
KinLok 4:dac7e60ec354 12 BusIn joy(p12,p13,p15,p16);
KinLok 4:dac7e60ec354 13 DigitalIn fire(p14);
KinLok 4:dac7e60ec354 14
KinLok 4:dac7e60ec354 15 BusOut leds(LED1,LED2,LED3,LED4);
KinLok 4:dac7e60ec354 16 AnalogIn p(p19);
KinLok 4:dac7e60ec354 17 AnalogIn p2(p20);
KinLok 4:dac7e60ec354 18 PwmOut spkr(p26);
KinLok 4:dac7e60ec354 19
chris 2:9e757151de9b 20 int main ()
KinLok 4:dac7e60ec354 21
okano 0:ce7a8546502b 22 {
okano 0:ce7a8546502b 23
chris 2:9e757151de9b 24 while (1) {
KinLok 4:dac7e60ec354 25 int a=p*80;
KinLok 4:dac7e60ec354 26
KinLok 4:dac7e60ec354 27 lcd.cls();
KinLok 4:dac7e60ec354 28
KinLok 4:dac7e60ec354 29 lcd.locate(0,3);//location of Temp. information sentence
KinLok 4:dac7e60ec354 30
KinLok 4:dac7e60ec354 31 lcd.printf("Room Temp. :%.2foC",tmp.read()); //Temp. information
KinLok 4:dac7e60ec354 32
KinLok 4:dac7e60ec354 33 lcd.locate(a,15); //location of LEDs state sentence
KinLok 4:dac7e60ec354 34
KinLok 4:dac7e60ec354 35 if (fire){//LEDs state
KinLok 4:dac7e60ec354 36
KinLok 4:dac7e60ec354 37 lcd.printf("ALL LED ON");
KinLok 4:dac7e60ec354 38 }
KinLok 4:dac7e60ec354 39 else if(leds == 0x1) {
KinLok 4:dac7e60ec354 40 lcd.printf("LED1 ON");
KinLok 4:dac7e60ec354 41 }
KinLok 4:dac7e60ec354 42 else if(leds == 0x2) {
KinLok 4:dac7e60ec354 43 lcd.printf("LED2 ON");
KinLok 4:dac7e60ec354 44 }
KinLok 4:dac7e60ec354 45 else if(leds == 0x4) {
KinLok 4:dac7e60ec354 46 lcd.printf("LED3 ON");
KinLok 4:dac7e60ec354 47 }
KinLok 4:dac7e60ec354 48 else if(leds == 0x8) {
KinLok 4:dac7e60ec354 49 lcd.printf("LED4 ON");
KinLok 4:dac7e60ec354 50 }
KinLok 4:dac7e60ec354 51 wait(0.1);
KinLok 4:dac7e60ec354 52 if (fire) {
KinLok 4:dac7e60ec354 53 leds=0xf;
KinLok 4:dac7e60ec354 54 for (float i=2000.0; i<10000.0; i+=100) {//speaker enable if all LEDs on
KinLok 4:dac7e60ec354 55 spkr.period(1.0/i);
KinLok 4:dac7e60ec354 56 spkr=p2;
KinLok 4:dac7e60ec354 57 wait(0.1);
KinLok 4:dac7e60ec354 58 }
KinLok 4:dac7e60ec354 59
KinLok 4:dac7e60ec354 60 } else {
KinLok 4:dac7e60ec354 61 leds=joy;
KinLok 4:dac7e60ec354 62 spkr = 0;
KinLok 4:dac7e60ec354 63 }
KinLok 4:dac7e60ec354 64
KinLok 4:dac7e60ec354 65 wait(0.1);
KinLok 4:dac7e60ec354 66
KinLok 4:dac7e60ec354 67
KinLok 4:dac7e60ec354 68 for(float i = 0.0; i < 1.0 ; i += 0.01) {
KinLok 4:dac7e60ec354 69 float p = (((tmp.read()/100)-0.298)*60);//rgb LED colour calculation
KinLok 4:dac7e60ec354 70 b = 1.0 - ((p < 1.0) ? 1.0 - p : (p > 2.0) ? p - 2.0 : 0.0);
KinLok 4:dac7e60ec354 71 g = 1.0 - ((p < 1.0) ? p : (p > 2.0) ? 0.0 : 2.0 - p);
KinLok 4:dac7e60ec354 72 r = 1.0 - ((p < 1.0) ? 0.0 : (p > 2.0) ? 3.0 - p : p - 1.0); ;
KinLok 4:dac7e60ec354 73 wait (0.01);
KinLok 4:dac7e60ec354 74
KinLok 4:dac7e60ec354 75 }
KinLok 4:dac7e60ec354 76
chris 2:9e757151de9b 77 }
okano 0:ce7a8546502b 78
KinLok 4:dac7e60ec354 79
okano 0:ce7a8546502b 80 }