Eduvance vanmat
/
08Switch_with_LCD
LCD interfacing with Switch
main.cpp
- Committer:
- Eduvance
- Date:
- 2014-05-27
- Revision:
- 1:4e5a747ab6eb
- Parent:
- 0:dea0c97faf15
File content as of revision 1:4e5a747ab6eb:
#include "mbed.h" #include "TextLCD.h" DigitalIn psw(p14); DigitalIn psw1(p15); DigitalIn psw2(p16); DigitalIn psw3(p17); TextLCD lcd(p25, p24, p23, p22, p21, p20, TextLCD::LCD16x2); int loop =10; int main() { lcd.cls(); // clear LCD screen lcd.printf(" switch and LCD "); lcd.locate(0,1); lcd.printf("A= ,B= ,C= ,D= "); while (loop>0){ if (psw == 1) {lcd.locate(2,1); lcd.printf("1"); } else {lcd.locate(2,1); lcd.printf("0");} if (psw1 == 1) {lcd.locate(6,1); lcd.printf("1"); } else {lcd.locate(6,1); lcd.printf("0");} if (psw2 == 1) {lcd.locate(10,1); lcd.printf("1"); } else {lcd.locate(10,1); lcd.printf("0");} if (psw3 == 1) {lcd.locate(14,1); lcd.printf("1"); } else {lcd.locate(14,1); lcd.printf("0");} } }