Mahandra Raditya / Mbed 2 deprecated LCDKEYPADTEST2

Dependencies:   TextLCD mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 
00002 // https://www.youtube.com/watch?v=yScO_v7NUYQ 
00003 // LEITURA DE BOTÕES
00004 
00005 #include "mbed.h"
00006 #include "TextLCD.h"
00007 
00008 
00009 //FRDM-K64F
00010 //TextLCD lcd(PTA0,PTC4,PTB23,PTA2,PTC2,PTC3); // rs, e, d4-d7
00011 TextLCD lcd(D8, D9, D4, D5, D6, D7); // rs, e, d4-d7
00012 Ticker      t;
00013 
00014 
00015                 
00016 AnalogIn Sensor(PTB2); //ESPECIFICA O PINO DE LEITURA ANALOGICA PARA FRDM-K64F 
00017 
00018 int main() {
00019     
00020     lcd.printf(" Calibration \n FRDM-K64F");
00021     wait(3);   
00022     lcd.cls();                                                      // Clean the display
00023     
00024         while(1){ 
00025         wait(1); 
00026         //lcd.locate(0,1);
00027         //float x=Sensor.read_u16(); 
00028         //lcd.printf("Value:(%f)",x);
00029         
00030         
00031             if(Sensor.read_u16()>12000 && Sensor.read_u16()< 15000){
00032                lcd.printf("Procedure \n will start");
00033                wait(3);
00034                lcd.cls(); 
00035                lcd.printf(" * Relax * ");
00036                wait(5);
00037                lcd.cls(); 
00038                lcd.printf(" * Stretch * ");
00039                wait(4);
00040                lcd.cls();                
00041                 } 
00042                 
00043             if(Sensor.read_u16()>46000 && Sensor.read_u16()< 48000){
00044                lcd.printf(" * left * ");
00045                wait(1);
00046                lcd.cls();                
00047                 } 
00048                 
00049             if(Sensor.read_u16()>30000 && Sensor.read_u16()< 32000){
00050                lcd.printf("  * down * ");
00051                wait(1);
00052                lcd.cls();                
00053                 } 
00054                 
00055             if(Sensor.read_u16()>0 && Sensor.read_u16()< 10000){
00056                lcd.printf("  * right * ");
00057                wait(1);
00058                lcd.cls();                       
00059                 }  
00060                 
00061             else {
00062                 lcd.printf("Press to start", Sensor.read_u16());
00063             wait(1);        
00064             lcd.cls();
00065             }
00066                    
00067                                         
00068         }
00069 
00070 }