Code:
#include "asuro.h"
#include "lcd.h"
const char Eye_L[8] PROGMEM = {0X00,0X00,0X1C,0X00,0X04,0X00,0X01,0X03};
const char Eye_R[8] PROGMEM = {0X00,0X00,0X07,0X00,0X04,0X00,0X10,0X18};
const char MouthA[8] PROGMEM = {0X00,0X00,0X02,0X01,0X00,0X00,0X00,0X00};
const char MouthB[8] PROGMEM = {0X03,0X01,0X00,0X00,0X18,0X07,0X00,0X00};
const char MouthC[8] PROGMEM = {0X18,0X10,0X00,0X00,0X03,0X1C,0X00,0X00};
const char MouthD[8] PROGMEM = {0X00,0X00,0X08,0X10,0X00,0X00,0X00,0X00};
void smily_load(void) //Nötige Sonderzeichen in das Display laden
{
lcd_setchar(0,Eye_L);
lcd_setchar(1,Eye_R);
lcd_setchar(4,MouthA);
lcd_setchar(5,MouthB);
lcd_setchar(6,MouthC);
lcd_setchar(7,MouthD);
}
void smily_draw(void) //Smily mit Sonderzeichen auf dem Display darstellen
{
lcd_home();
lcd_gotoxy(2,0);
lcd_putc('('); //linkes Ohr
lcd_putc(0); //linkes Auge
lcd_putc(1); //rechtes Auge
lcd_putc(')'); //rechtes Ohr
lcd_gotoxy(2,1);
lcd_putc(4); //Mund A
lcd_putc(5); //Mund B
lcd_putc(6); //Mund C
lcd_putc(7); //Mund D
}
int main(void)
{
while(1)
{
unsigned char i;
unsigned char taste=0;
Init();
lcd_init(LCD_DISP_ON);
for(i=0;i<10;i++)
{
PollSwitch();
}
taste=PollSwitch();
if (taste==0)
{
MotorDir(FWD,FWD);
MotorSpeed(200,200);
smily_load();
smily_draw();
}
else
{
MotorSpeed(0,0);
BackLED(ON,ON);
Sleep(100);
for(i=0; i<210; i++)
{
MotorDir(RWD,RWD);
MotorSpeed(130,130);
Sleep(100);
MotorSpeed(0,0);
lcd_init(LCD_DISP_ON_CURSOR_BLINK);
lcd_puts("Ich bin");
lcd_gotoxy(3,1); lcd_puts_P("ASURO");
}
for(i=0; i<140; i++)
{
MotorDir(FWD,RWD);
MotorSpeed(140,140);
Sleep(100);
}
BackLED(OFF,OFF);
}
Sleep(100);
}
return 0;
}
Damit habe ich leider Probleme: Während der ASURO durchs Zimmer fährt soll das Gesicht angezeigt werden. Bei Betätigung eines Tasters (anstossen) soll das Display wechseln zu "Ich bin Asuro", der Asuro eine Kehrwendung machen und das Display wieder zurückwechseln.
Lesezeichen