Masakazu Enomoto / Mbed 2 deprecated TextLCD_flow

Dependencies:   TextLCD mbed

Fork of TextLCD_HelloWorld by Simon Ford

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(p24, p26, p27, p28, p29, p30);
00005 
00006 int main(void) {
00007     int x = 0, y = 0;
00008 
00009     lcd.cls();
00010     lcd.locate(0, 0);
00011     lcd.printf("A");
00012 
00013     while(-1) {
00014         y = y % 2;
00015         switch(y){
00016             case 0:
00017                 x++;
00018                 break;
00019             case 1:
00020                 x--;
00021                 break;
00022             default:
00023                 break;
00024         }
00025         wait(0.5);
00026         lcd.cls();
00027         lcd.locate(x, y);
00028         lcd.printf("A");
00029         
00030         if(x == 0 && y == 1){
00031             x--;
00032             y = 0;
00033         }
00034         if(x == 15 && y == 0){
00035             x++;
00036             y = 1;
00037         }
00038     }
00039 }