@damaltor
vielen Dank, habs jetzt größtenteils verstanden!
Hab BackLED-Funktionen geschrieben, mit denen man sie auch glimmen lassen kann:
Code:
//------------------------------------------------------------------
//backled-spielchen
//------------------------------------------------------------------
#include "asuro.h"
//------------------------------------------------------------------
//backled funktionen um die leds unabhängig voneinander
//hell leuchten oder glimmen zu lassen
//------------------------------------------------------------------
#define aus 0
#define hell 1
#define glimm 2
//------------------------------------------------------------------
// rechte led
void BackLEDrechts(uint8_t status) // aus - hell - glimm
{
PORTD &= ~(1 << PD7); //odoleds aus
if (status == aus)
{ //rechte backled aus
DDRC |= (1 << PC0); //rechts auf out
PORTC &= ~(1 << PC0); //rechte aus
}
if (status == hell)
{
//rechte backled hell
DDRC |= (1 << PC0); //rechts auf out
PORTC |= (1 << PC0); //rechte an
}
if (status == glimm)
{ //rechte backled glimmt
DDRC &= ~(1 << PC0); //rechts auf in
}
}
//------------------------------------------------------------------
// linke led
void BackLEDlinks(uint8_t status) // aus - hell - glimm
{
PORTD &= ~(1 << PD7); //odoleds aus
if (status == aus)
{ //rechte backled aus
DDRC |= (1 << PC1); //links auf out
PORTC &= ~(1 << PC1); //linke aus
}
if (status == hell)
{
//rechte backled hell
DDRC |= (1 << PC1); //links auf out
PORTC |= (1 << PC1); //linke an
}
if (status == glimm)
{ //rechte backled glimmt
DDRC &= ~(1 << PC1); //links auf in
}
}
//------------------------------------------------------------------
//------------------------------------------------------------------
uint8_t i;
//------------------------------------------------------------------
// hauptprogramm
//------------------------------------------------------------------
int main(void)
{
Init();
BackLEDrechts(aus);
BackLEDlinks(aus);
StatusLED(GREEN);
Msleep(1000);
for(i = 1; i <= 5; ++i)
{
BackLEDrechts(glimm);
BackLEDlinks(glimm);
Msleep(500);
BackLEDrechts(hell);
BackLEDlinks(hell);
Msleep(500);
}
BackLEDrechts(aus);
BackLEDlinks(aus);
Msleep(500);
for(i = 1; i <= 5; ++i)
{
BackLEDrechts(hell);
BackLEDlinks(glimm);
Msleep(500);
BackLEDrechts(glimm);
BackLEDlinks(hell);
Msleep(500);
}
BackLEDrechts(aus);
BackLEDlinks(aus);
Msleep(500);
for(i = 1; i <= 5; ++i)
{
BackLEDrechts(aus);
BackLEDlinks(glimm);
Msleep(500);
BackLEDrechts(glimm);
BackLEDlinks(aus);
Msleep(500);
}
BackLEDrechts(aus);
BackLEDlinks(aus);
StatusLED(RED);
while (1);
return 0;
}
Gruss
M.
Lesezeichen