Eduvance vanmat / Mbed 2 deprecated 08Switch_with_LCD

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 DigitalIn psw(p14);
00005 DigitalIn psw1(p15);
00006 DigitalIn psw2(p16);
00007 DigitalIn psw3(p17);
00008 
00009 TextLCD lcd(p25, p24, p23, p22, p21, p20, TextLCD::LCD16x2); 
00010 int loop =10;
00011 
00012 int main() {
00013   lcd.cls();                      //  clear LCD screen
00014     lcd.printf(" switch and LCD ");
00015     lcd.locate(0,1);
00016     lcd.printf("A= ,B= ,C= ,D= ");
00017   while (loop>0){
00018       if (psw == 1)
00019       {lcd.locate(2,1);
00020       lcd.printf("1");
00021       }
00022       else {lcd.locate(2,1);
00023             lcd.printf("0");}
00024       if (psw1 == 1)
00025       {lcd.locate(6,1);
00026       lcd.printf("1");
00027       }
00028       else {lcd.locate(6,1);
00029             lcd.printf("0");}
00030        
00031       
00032       if (psw2 == 1)
00033       {lcd.locate(10,1);
00034       lcd.printf("1");
00035       }
00036       else {lcd.locate(10,1);
00037             lcd.printf("0");} 
00038             
00039       if (psw3 == 1)
00040       {lcd.locate(14,1);
00041       lcd.printf("1");
00042       }
00043       else {lcd.locate(14,1);
00044             lcd.printf("0");}      
00045 }
00046 }