han back / Mbed OS CLEO_IR
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "TextLCD.h"
00003 
00004 PinName pin_IR_A = PC_0;
00005 PinName pin_IR_D = PC_12;
00006 
00007 AnalogIn adc_IR(pin_IR_A);
00008 DigitalIn IR(pin_IR_D);
00009 
00010 // rs, rw, e, d0-d3
00011 TextLCD lcd(PB_12, PB_13, PB_14, PB_15, PA_9, PA_10, PA_11); 
00012 
00013 int main() {
00014     
00015     int volt, ir_d;
00016     lcd.printf(" Volt :     [mV]"); 
00017     lcd.locate(0, 1);
00018     lcd.printf(" IR Status : "); 
00019     while(1) {
00020         volt = adc_IR.read()*3300;
00021         ir_d = IR;
00022         lcd.locate(8, 0);
00023         lcd.printf("%4d", volt);
00024         lcd.locate(13, 1);
00025         lcd.printf("%d", ir_d);
00026         wait(1);
00027     }
00028 }