Willkommen auf unserem Seminar-Blog

Immer auf dem aktuellen Stand bleiben

Dieser Seminar-Blog befindet sich noch im Aufbau und wird in den kommenden Tagen entsprechend verfeinert.

Member Login

Lost your password?

Registration is closed

Sorry, you are not allowed to register by yourself on this site!

You must either be invited by one of our team member or request an invitation by email at viad.info {at} zhdk {dot} ch.

08 Dot-Matrix Basics & Shifting

14. November 2011

    Als erste Aufgabe bastelten wir uns ein Lauflicht ähnlich des Knight Rider Autos ' K.I.T '. Die zweite Aufgabe bestand darin, eine Art Animation zu generieren. Diese wird durch  schnell aufeinander folgende Bilder generiert.

#define LED_MINUS_1 2
#define LED_MINUS_2 3
#define LED_MINUS_3 4
#define LED_MINUS_4 5
#define LED_MINUS_5 6

#define LED_PLUS_1 7
#define LED_PLUS_2 8
#define LED_PLUS_3 9
#define LED_PLUS_4 10
#define LED_PLUS_5 11
#define LED_PLUS_6 12
#define LED_PLUS_7 13

int colum[5] = { LED_MINUS_1, LED_MINUS_2, LED_MINUS_3, LED_MINUS_4, LED_MINUS_5};
int row[7] = { LED_PLUS_1, LED_PLUS_2, LED_PLUS_3, LED_PLUS_4, LED_PLUS_5, LED_PLUS_6, LED_PLUS_7};

int verzug = 200;
int counter= 0;
int x = 0;

void setup()
{
for(int i = 2; i <= 12; i++)
{
pinMode(i, OUTPUT);
}
for(int i = 2; i <= 6; i++)
{
digitalWrite(i, HIGH);
}
for(int i = 7; i <= 13; i++)
{
digitalWrite(i, LOW);
}
}

void loop()
{

if (counter >= verzug)
{
x++;
counter = 0;

if(x>14)
{
x=0;
}
}
counter++;

if(x==0)
{
//Bild 1
pulseLED(2, 6);
}
else if(x==1)
{
//Bild 2
pulseLED(2, 5);
pulseLED(2, 4);
pulseLED(1, 6);
pulseLED(3, 6);
}
else if(x==2)
{
//Bild 3

pulseLED(2, 4);
pulseLED(2, 5);
pulseLED(2, 6);
pulseLED(1, 5);
pulseLED(3, 5);
pulseLED(0, 6);
pulseLED(4, 6);
}
else if(x==3)
{
//Bild 4

pulseLED(2, 3);
pulseLED(2, 4);
pulseLED(2, 5);
pulseLED(2, 6);
pulseLED(1, 4);
pulseLED(3, 4);
pulseLED(0, 5);
pulseLED(4, 5);
}
else if(x==5)
{
//Bild 5

pulseLED(2, 2);
pulseLED(2, 3);
pulseLED(2, 4);
pulseLED(2, 5);
pulseLED(2, 6);
pulseLED(1, 3);
pulseLED(3, 3);
pulseLED(0, 4);
pulseLED(4, 4);
}
else if (x==6)
{
//Bild 5

pulseLED(2, 1);
pulseLED(2, 2);
pulseLED(2, 3);
pulseLED(2, 4);
pulseLED(2, 5);
pulseLED(2, 6);
pulseLED(1, 2);
pulseLED(3, 2);
pulseLED(0, 3);
pulseLED(4, 3);
}
else if(x==7)
{
//Bild6
pulseLED(2, 6);
pulseLED(2, 5);
pulseLED(2, 4);
pulseLED(2, 3);
pulseLED(2, 2);
pulseLED(2, 1);
pulseLED(2, 0);

pulseLED(1, 1);
pulseLED(0, 2);
pulseLED(3, 1);
pulseLED(4, 2);
}
else if(x==8)
{
//Bild7
pulseLED(2, 5);
pulseLED(2, 4);
pulseLED(2, 3);
pulseLED(2, 2);
pulseLED(2, 1);
pulseLED(2, 0);

pulseLED(1, 0);
pulseLED(0, 1);
pulseLED(3, 0);
pulseLED(4, 1);
}
else if(x== 9)
{
//Bild8
pulseLED(2, 4);
pulseLED(2, 3);
pulseLED(2, 2);
pulseLED(2, 1);
pulseLED(2, 0);

pulseLED(0, 0);
pulseLED(4, 0);
}

else if (x==10)
{
//Bild9
pulseLED(2, 3);
pulseLED(2, 2);
pulseLED(2, 1);
pulseLED(2, 0);
}
else if (x==11)
{
//Bild10
pulseLED(2, 2);
pulseLED(2, 1);
pulseLED(2, 0);
}
else if (x==12)
{
//Bild11
pulseLED(2, 1);
pulseLED(2, 0);
}
else if (x==13)
{
//Bild12
pulseLED(2, 0);
}

else if (x==14)
{
//Bild12
}

}

void pulseLED(int whichColum, int whichRow)
{
digitalWrite(colum[whichColum], LOW);
digitalWrite(row[whichRow], HIGH);
delayMicroseconds(100);
digitalWrite(colum[whichColum], HIGH);
digitalWrite(row[whichRow], LOW);
}