☆Board Orange の液晶上を文字が流れます。

Dependencies:   TextLCD mbed

Fork of TextLCD_HelloWorld by Simon Ford

main.cpp

Committer:
20140318
Date:
2014-11-13
Revision:
3:9cffa51c74dc
Parent:
2:ad0b044d0a10

File content as of revision 3:9cffa51c74dc:

#include "mbed.h"
#include "TextLCD.h"

TextLCD lcd(p24, p26, p27, p28, p29, p30);

int main(void) {
    int x = 0, y = 0;

    lcd.cls();
    lcd.locate(0, 0);
    lcd.printf("A");

    while(-1) {
        y = y % 2;
        switch(y){
            case 0:
                x++;
                break;
            case 1:
                x--;
                break;
            default:
                break;
        }
        wait(0.5);
        lcd.cls();
        lcd.locate(x, y);
        lcd.printf("A");
        
        if(x == 0 && y == 1){
            x--;
            y = 0;
        }
        if(x == 15 && y == 0){
            x++;
            y = 1;
        }
    }
}