Prof. DI Hans Michael Hollegha
05_12_2019
Leds.cpp
// LSB MSB
// 2^0 2^1 2^2 2^3 2^7
void BitsSetzen ();
void RunLight1();
void RunLight2();
void main ()
{
while(1)
{
RunLight2();
}
}
void RunLight1()
{
lb= 1;
wait_ms(100);
for(int i=1; i<=7; i++)
{
lb = lb << 1; // nach Rechts
wait_ms(100);
}
}
void RunLight2()
{
lb= 1;
wait_ms(100);
for(int i=1; i<=2; i++)
{
lb = lb << 1;
lb = lb | 1;
wait_ms(500);
}
void BitsSetzen ()
{
lb = 1; //B#0001 D2 leuchtet
wait_ms(500);
lb = 2; //B#0010 D3 leuchtet
wait_ms(500);
lb = 4; //B#0100 D6 leuchtet
wait_ms (500);
lb = 8; //B#1000 D9 leuchtet
wait_ms (500);
lb = 16; //B#00010000 D9 leuchtet
wait_ms (500);
lb = 32; //
wait_ms (500);
lb = 64; //
wait_ms (500);
lb = 128; //
wait_ms (500);
}