![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
-
main.cpp@0:d84281c81bec, 2019-06-06 (annotated)
- Committer:
- meksc
- Date:
- Thu Jun 06 14:15:56 2019 +0000
- Revision:
- 0:d84281c81bec
-
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
meksc | 0:d84281c81bec | 1 | #include "mbed.h" |
meksc | 0:d84281c81bec | 2 | #include "TextLCD.h" |
meksc | 0:d84281c81bec | 3 | |
meksc | 0:d84281c81bec | 4 | DigitalOut myled(PC_13); |
meksc | 0:d84281c81bec | 5 | AnalogIn adc(PA_0); |
meksc | 0:d84281c81bec | 6 | Serial serial(PA_9, PA_10); |
meksc | 0:d84281c81bec | 7 | |
meksc | 0:d84281c81bec | 8 | TextLCD lcd(PA_4,PA_5,PA_6,PB_12,PB_13,PB_14,PB_15); |
meksc | 0:d84281c81bec | 9 | int main() { |
meksc | 0:d84281c81bec | 10 | serial.baud(115200); |
meksc | 0:d84281c81bec | 11 | float tensao; |
meksc | 0:d84281c81bec | 12 | |
meksc | 0:d84281c81bec | 13 | while(1) { |
meksc | 0:d84281c81bec | 14 | tensao=3.3*adc.read(); |
meksc | 0:d84281c81bec | 15 | lcd.gotoxy(1,1); |
meksc | 0:d84281c81bec | 16 | lcd.printf("Tensao: %.2f",tensao); |
meksc | 0:d84281c81bec | 17 | serial.printf ("Tensao: %.2f\n",tensao); |
meksc | 0:d84281c81bec | 18 | myled = 1; // LED is ON |
meksc | 0:d84281c81bec | 19 | wait(0.2); // 200 ms |
meksc | 0:d84281c81bec | 20 | myled = 0; // LED is OFF |
meksc | 0:d84281c81bec | 21 | wait(1.0); // 1 sec |
meksc | 0:d84281c81bec | 22 | } |
meksc | 0:d84281c81bec | 23 | } |