Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp@0:68fe010d5a55, 2017-11-02 (annotated)
- Committer:
- Sunastra
- Date:
- Thu Nov 02 10:05:21 2017 +0000
- Revision:
- 0:68fe010d5a55
Simple LCD test with button commands
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Sunastra | 0:68fe010d5a55 | 1 | |
| Sunastra | 0:68fe010d5a55 | 2 | // https://www.youtube.com/watch?v=yScO_v7NUYQ |
| Sunastra | 0:68fe010d5a55 | 3 | // LEITURA DE BOTÕES |
| Sunastra | 0:68fe010d5a55 | 4 | |
| Sunastra | 0:68fe010d5a55 | 5 | #include "mbed.h" |
| Sunastra | 0:68fe010d5a55 | 6 | #include "TextLCD.h" |
| Sunastra | 0:68fe010d5a55 | 7 | |
| Sunastra | 0:68fe010d5a55 | 8 | |
| Sunastra | 0:68fe010d5a55 | 9 | //FRDM-K64F |
| Sunastra | 0:68fe010d5a55 | 10 | //TextLCD lcd(PTA0,PTC4,PTB23,PTA2,PTC2,PTC3); // rs, e, d4-d7 |
| Sunastra | 0:68fe010d5a55 | 11 | TextLCD lcd(D8, D9, D4, D5, D6, D7); // rs, e, d4-d7 |
| Sunastra | 0:68fe010d5a55 | 12 | Ticker t; |
| Sunastra | 0:68fe010d5a55 | 13 | |
| Sunastra | 0:68fe010d5a55 | 14 | |
| Sunastra | 0:68fe010d5a55 | 15 | |
| Sunastra | 0:68fe010d5a55 | 16 | AnalogIn Sensor(PTB2); //ESPECIFICA O PINO DE LEITURA ANALOGICA PARA FRDM-K64F |
| Sunastra | 0:68fe010d5a55 | 17 | |
| Sunastra | 0:68fe010d5a55 | 18 | int main() { |
| Sunastra | 0:68fe010d5a55 | 19 | |
| Sunastra | 0:68fe010d5a55 | 20 | lcd.printf(" Calibration \n FRDM-K64F"); |
| Sunastra | 0:68fe010d5a55 | 21 | wait(3); |
| Sunastra | 0:68fe010d5a55 | 22 | lcd.cls(); // Clean the display |
| Sunastra | 0:68fe010d5a55 | 23 | |
| Sunastra | 0:68fe010d5a55 | 24 | while(1){ |
| Sunastra | 0:68fe010d5a55 | 25 | wait(1); |
| Sunastra | 0:68fe010d5a55 | 26 | //lcd.locate(0,1); |
| Sunastra | 0:68fe010d5a55 | 27 | //float x=Sensor.read_u16(); |
| Sunastra | 0:68fe010d5a55 | 28 | //lcd.printf("Value:(%f)",x); |
| Sunastra | 0:68fe010d5a55 | 29 | |
| Sunastra | 0:68fe010d5a55 | 30 | |
| Sunastra | 0:68fe010d5a55 | 31 | if(Sensor.read_u16()>12000 && Sensor.read_u16()< 15000){ |
| Sunastra | 0:68fe010d5a55 | 32 | lcd.printf("Procedure \n will start"); |
| Sunastra | 0:68fe010d5a55 | 33 | wait(3); |
| Sunastra | 0:68fe010d5a55 | 34 | lcd.cls(); |
| Sunastra | 0:68fe010d5a55 | 35 | lcd.printf(" * Relax * "); |
| Sunastra | 0:68fe010d5a55 | 36 | wait(5); |
| Sunastra | 0:68fe010d5a55 | 37 | lcd.cls(); |
| Sunastra | 0:68fe010d5a55 | 38 | lcd.printf(" * Stretch * "); |
| Sunastra | 0:68fe010d5a55 | 39 | wait(4); |
| Sunastra | 0:68fe010d5a55 | 40 | lcd.cls(); |
| Sunastra | 0:68fe010d5a55 | 41 | } |
| Sunastra | 0:68fe010d5a55 | 42 | |
| Sunastra | 0:68fe010d5a55 | 43 | if(Sensor.read_u16()>46000 && Sensor.read_u16()< 48000){ |
| Sunastra | 0:68fe010d5a55 | 44 | lcd.printf(" * left * "); |
| Sunastra | 0:68fe010d5a55 | 45 | wait(1); |
| Sunastra | 0:68fe010d5a55 | 46 | lcd.cls(); |
| Sunastra | 0:68fe010d5a55 | 47 | } |
| Sunastra | 0:68fe010d5a55 | 48 | |
| Sunastra | 0:68fe010d5a55 | 49 | if(Sensor.read_u16()>30000 && Sensor.read_u16()< 32000){ |
| Sunastra | 0:68fe010d5a55 | 50 | lcd.printf(" * down * "); |
| Sunastra | 0:68fe010d5a55 | 51 | wait(1); |
| Sunastra | 0:68fe010d5a55 | 52 | lcd.cls(); |
| Sunastra | 0:68fe010d5a55 | 53 | } |
| Sunastra | 0:68fe010d5a55 | 54 | |
| Sunastra | 0:68fe010d5a55 | 55 | if(Sensor.read_u16()>0 && Sensor.read_u16()< 10000){ |
| Sunastra | 0:68fe010d5a55 | 56 | lcd.printf(" * right * "); |
| Sunastra | 0:68fe010d5a55 | 57 | wait(1); |
| Sunastra | 0:68fe010d5a55 | 58 | lcd.cls(); |
| Sunastra | 0:68fe010d5a55 | 59 | } |
| Sunastra | 0:68fe010d5a55 | 60 | |
| Sunastra | 0:68fe010d5a55 | 61 | else { |
| Sunastra | 0:68fe010d5a55 | 62 | lcd.printf("Press to start", Sensor.read_u16()); |
| Sunastra | 0:68fe010d5a55 | 63 | wait(1); |
| Sunastra | 0:68fe010d5a55 | 64 | lcd.cls(); |
| Sunastra | 0:68fe010d5a55 | 65 | } |
| Sunastra | 0:68fe010d5a55 | 66 | |
| Sunastra | 0:68fe010d5a55 | 67 | |
| Sunastra | 0:68fe010d5a55 | 68 | } |
| Sunastra | 0:68fe010d5a55 | 69 | |
| Sunastra | 0:68fe010d5a55 | 70 | } |