Israel Hernández Orozco / Mbed 2 deprecated 8_2

Dependencies:   mbed TextLCD

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 TextLCD lcd(D4,D5,A2,A3,A4,A5); // rs, e, d4-d7
00005 AnalogIn val1(A0);
00006 AnalogIn val2(A1);
00007 DigitalOut motor(D6);
00008 Ticker  flipper;
00009 float v1;
00010 float v2;
00011 float lima = 25.0f;
00012 float limb = 18.0f;
00013 
00014 void  flip()  {  
00015     v1 = val1;
00016     v2 = val2;
00017     v1 = v1 * 33.3f;
00018     v2 = v2 * 33.3f;
00019 } 
00020 int main() {
00021     flipper.attach(&flip, 0.4);  
00022     while(1) {
00023         lcd.printf("V1= %f C\nV2= %f C", v1,v2);
00024         wait(0.2);
00025         lcd.cls();
00026         if(v1>=lima && v2<=limb) {
00027             motor = 1;
00028             }
00029         else motor = 0;
00030     }
00031 }