nikos chalikias
/
n-bed_LCD_ADC_RTC
testing n-bed
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 // N.C. testing n-bed with LCD 00002 00003 #include "mbed.h" 00004 #include "TextLCD.h" 00005 00006 //n-bed CONNECTOR "L" JP6 00007 TextLCD lcd(p17, p20, p24, p23, p22, p8, TextLCD::LCD20x4); // rs, e, d4-d7 00008 00009 //n-bed CONNECTOR "K" JP7 00010 //Drive LCD from NON mbed pins 00011 TextLCD lcd2(P1_19, P1_22, p15, P1_25, P1_26, P1_27, TextLCD::LCD20x4); // rs, e, d4-d7 00012 00013 Timer t; 00014 DigitalOut led1(LED1); 00015 00016 //Measure from a NON mbed analog pin 00017 AnalogIn input(P0_2); //the range of the analog input goes, from 0 V. to 3.3V. the actual value is represented as a float from 0 to 1. 00018 float ain; //ain must be a float, for matching the input.read type. 00019 AnalogIn input2(P0_3); //the range of the analog input goes, from 0 V. to 3.3V. the actual value is represented as a float from 0 to 1. 00020 float ain2; //ain must be a float, for matching the input.read type. 00021 00022 int main() { 00023 t.start(); 00024 lcd.cls(); 00025 wait(1); 00026 lcd.printf("n-bed 1st Display\n"); lcd2.printf("n-bed 2nd Display\n"); 00027 while (1) { 00028 led1 = 1; 00029 ain=input.read(); 00030 00031 time_t seconds = time(NULL); 00032 lcd.locate(0,1); lcd2.locate(0,1); 00033 lcd.printf("%s", ctime(&seconds)); lcd2.printf("%s", ctime(&seconds)); 00034 00035 lcd.locate(0,2); lcd2.locate(0,2); 00036 lcd.printf("n-bed A3=%1.1f V", ( float(3.3)*ain) ) ; lcd2.printf("n-bed A3=%1.1f V", ( float(3.3)*ain) ) ; 00037 wait(0.001); 00038 ain2=input2.read(); 00039 lcd.locate(0,3); lcd2.locate(0,3); 00040 lcd.printf("n-bed A4=%1.1f V", ( float(3.3)*ain2) ) ; lcd2.printf("n-bed A4=%1.1f V", ( float(3.3)*ain2) ) ; 00041 led1 = 0; 00042 wait(0.9); 00043 } 00044 } 00045 00046 00047 00048
Generated on Wed Jul 20 2022 03:17:58 by 1.7.2