Ganesh Gore
/
LnTMadhExe1
test code to log ldr value
main.cpp@0:e2162e735bfe, 2017-01-05 (annotated)
- Committer:
- ganesh70508
- Date:
- Thu Jan 05 11:00:59 2017 +0000
- Revision:
- 0:e2162e735bfe
initial;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ganesh70508 | 0:e2162e735bfe | 1 | #include "mbed.h" |
ganesh70508 | 0:e2162e735bfe | 2 | |
ganesh70508 | 0:e2162e735bfe | 3 | AnalogIn ldr(PTB1); |
ganesh70508 | 0:e2162e735bfe | 4 | Serial pc(USBTX, USBRX); // tx, rx |
ganesh70508 | 0:e2162e735bfe | 5 | int main() { |
ganesh70508 | 0:e2162e735bfe | 6 | unsigned int value; |
ganesh70508 | 0:e2162e735bfe | 7 | while(1) { |
ganesh70508 | 0:e2162e735bfe | 8 | if(pc.readable()) { |
ganesh70508 | 0:e2162e735bfe | 9 | if (pc.getc() == 'A') |
ganesh70508 | 0:e2162e735bfe | 10 | value = ldr*100.0; |
ganesh70508 | 0:e2162e735bfe | 11 | pc.printf("%2d\n",value); |
ganesh70508 | 0:e2162e735bfe | 12 | } |
ganesh70508 | 0:e2162e735bfe | 13 | wait(0.01); |
ganesh70508 | 0:e2162e735bfe | 14 | } |
ganesh70508 | 0:e2162e735bfe | 15 | } |