khairul irwan fikri mohammad / Mbed 2 deprecated prac_test

Dependencies:   TextLCD mbed

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(D8, D9, D4, D5, D6, D7);
00005 Serial pc(USBTX, USBRX);
00006 DigitalIn switch1(PC_3);
00007 
00008 int x=0;
00009 int main() {
00010     lcd.locate(0,0);
00011     lcd.printf("embedded");
00012     lcd.locate(2,1);
00013     lcd.printf("subject");
00014     pc.printf("embedded subject\n");
00015     while(1) {
00016         if(switch1 > 0.1f) {
00017             for (x = 99; x > 65; x--){
00018                 lcd.locate(12,0);
00019                 lcd.printf("%d",x);
00020                 pc.printf("%d \n\r",x);
00021                 wait(0.5);
00022                 x=x-2;
00023                 if(switch1<0.1f){
00024                     x=66;}
00025                 }
00026             } 
00027             else {
00028             for (x = 99; x > 65; x--){
00029                 if(switch1>0.1f){
00030                     x=66;}
00031                 lcd.locate(12,0);
00032                 lcd.printf("%d",x);
00033                 pc.printf("%d \n\r",x);
00034                 wait(0.5);
00035                 }
00036         }
00037         
00038     }
00039 }