lye cypher
/
SSD541_HW_52a
ES_SD541_HW52a
Fork of lightsense_kl46z_basic by
main.cpp@10:cccc6a1739be, 2016-09-19 (annotated)
- Committer:
- eseifert
- Date:
- Mon Sep 19 12:18:34 2016 +0000
- Revision:
- 10:cccc6a1739be
- Parent:
- 9:f619cdaa7a65
ES_SSD541_HW_52a
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
scohennm | 0:e23fffd4b9a7 | 1 | #include "mbed.h" |
scohennm | 1:51f8c2b04ce2 | 2 | #include "SLCD.h" |
scohennm | 1:51f8c2b04ce2 | 3 | |
scohennm | 3:64e28ee5719b | 4 | |
scohennm | 9:f619cdaa7a65 | 5 | #define PROGNAME "lightsense_kl46z_basic v1\n\r" |
scohennm | 8:3b19ecdc4261 | 6 | #define DATATIME 400 // milliseconds |
scohennm | 1:51f8c2b04ce2 | 7 | #define LCDLEN 10 |
scohennm | 8:3b19ecdc4261 | 8 | #define LIGHTSENSORPORT PTE22 |
scohennm | 6:710e18c552f5 | 9 | |
scohennm | 6:710e18c552f5 | 10 | |
scohennm | 0:e23fffd4b9a7 | 11 | |
scohennm | 4:bd42ab18979b | 12 | SLCD slcd; //define LCD display globally define |
scohennm | 1:51f8c2b04ce2 | 13 | Serial pc(USBTX, USBRX); |
scohennm | 8:3b19ecdc4261 | 14 | Timer LEDTimer; |
scohennm | 1:51f8c2b04ce2 | 15 | |
eseifert | 10:cccc6a1739be | 16 | void LCDMess(char *lMess) |
eseifert | 10:cccc6a1739be | 17 | { |
eseifert | 10:cccc6a1739be | 18 | slcd.Home(); |
eseifert | 10:cccc6a1739be | 19 | slcd.clear(); |
eseifert | 10:cccc6a1739be | 20 | slcd.printf(lMess); |
eseifert | 10:cccc6a1739be | 21 | } |
scohennm | 0:e23fffd4b9a7 | 22 | |
eseifert | 10:cccc6a1739be | 23 | int main() |
eseifert | 10:cccc6a1739be | 24 | { |
scohennm | 8:3b19ecdc4261 | 25 | AnalogIn LightSensor(LIGHTSENSORPORT); |
eseifert | 10:cccc6a1739be | 26 | float lightData; |
scohennm | 1:51f8c2b04ce2 | 27 | char lcdData[LCDLEN]; |
eseifert | 10:cccc6a1739be | 28 | |
scohennm | 8:3b19ecdc4261 | 29 | int timeToChangeDF = DATATIME; |
scohennm | 3:64e28ee5719b | 30 | LEDTimer.start(); |
scohennm | 3:64e28ee5719b | 31 | LEDTimer.reset(); |
scohennm | 1:51f8c2b04ce2 | 32 | pc.printf(PROGNAME); |
eseifert | 10:cccc6a1739be | 33 | PwmOut gled(LED_GREEN); |
eseifert | 10:cccc6a1739be | 34 | PwmOut rled(LED_RED); |
eseifert | 10:cccc6a1739be | 35 | |
eseifert | 10:cccc6a1739be | 36 | while(true) { |
eseifert | 10:cccc6a1739be | 37 | if (LEDTimer.read_ms() > timeToChangeDF) { // check for timer time out transtion |
eseifert | 10:cccc6a1739be | 38 | lightData = (1.0 - LightSensor.read()); // show as increasiing with increasing intensity |
eseifert | 10:cccc6a1739be | 39 | sprintf(lcdData,"%4.3f",lightData); |
eseifert | 10:cccc6a1739be | 40 | LCDMess(lcdData); |
eseifert | 10:cccc6a1739be | 41 | gled = lightData; |
eseifert | 10:cccc6a1739be | 42 | rled = lightData; |
scohennm | 8:3b19ecdc4261 | 43 | timeToChangeDF = DATATIME; |
scohennm | 8:3b19ecdc4261 | 44 | LEDTimer.reset(); |
eseifert | 10:cccc6a1739be | 45 | } |
scohennm | 4:bd42ab18979b | 46 | }// emd while |
scohennm | 4:bd42ab18979b | 47 | } |