han back
/
CLEO_IR
SMART CLEO IR
main.cpp@0:d200cffd7784, 2017-09-28 (annotated)
- Committer:
- SMART_CLEO
- Date:
- Thu Sep 28 02:59:46 2017 +0000
- Revision:
- 0:d200cffd7784
SMART_CLEO
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
SMART_CLEO | 0:d200cffd7784 | 1 | #include "mbed.h" |
SMART_CLEO | 0:d200cffd7784 | 2 | #include "TextLCD.h" |
SMART_CLEO | 0:d200cffd7784 | 3 | |
SMART_CLEO | 0:d200cffd7784 | 4 | PinName pin_IR_A = PC_0; |
SMART_CLEO | 0:d200cffd7784 | 5 | PinName pin_IR_D = PC_12; |
SMART_CLEO | 0:d200cffd7784 | 6 | |
SMART_CLEO | 0:d200cffd7784 | 7 | AnalogIn adc_IR(pin_IR_A); |
SMART_CLEO | 0:d200cffd7784 | 8 | DigitalIn IR(pin_IR_D); |
SMART_CLEO | 0:d200cffd7784 | 9 | |
SMART_CLEO | 0:d200cffd7784 | 10 | // rs, rw, e, d0-d3 |
SMART_CLEO | 0:d200cffd7784 | 11 | TextLCD lcd(PB_12, PB_13, PB_14, PB_15, PA_9, PA_10, PA_11); |
SMART_CLEO | 0:d200cffd7784 | 12 | |
SMART_CLEO | 0:d200cffd7784 | 13 | int main() { |
SMART_CLEO | 0:d200cffd7784 | 14 | |
SMART_CLEO | 0:d200cffd7784 | 15 | int volt, ir_d; |
SMART_CLEO | 0:d200cffd7784 | 16 | lcd.printf(" Volt : [mV]"); |
SMART_CLEO | 0:d200cffd7784 | 17 | lcd.locate(0, 1); |
SMART_CLEO | 0:d200cffd7784 | 18 | lcd.printf(" IR Status : "); |
SMART_CLEO | 0:d200cffd7784 | 19 | while(1) { |
SMART_CLEO | 0:d200cffd7784 | 20 | volt = adc_IR.read()*3300; |
SMART_CLEO | 0:d200cffd7784 | 21 | ir_d = IR; |
SMART_CLEO | 0:d200cffd7784 | 22 | lcd.locate(8, 0); |
SMART_CLEO | 0:d200cffd7784 | 23 | lcd.printf("%4d", volt); |
SMART_CLEO | 0:d200cffd7784 | 24 | lcd.locate(13, 1); |
SMART_CLEO | 0:d200cffd7784 | 25 | lcd.printf("%d", ir_d); |
SMART_CLEO | 0:d200cffd7784 | 26 | wait(1); |
SMART_CLEO | 0:d200cffd7784 | 27 | } |
SMART_CLEO | 0:d200cffd7784 | 28 | } |