|
|
|
@ -12,17 +12,31 @@
|
|
|
|
|
#define F_CPU 1000000
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
|
/* function declarations */
|
|
|
|
|
void task1 ();
|
|
|
|
|
|
|
|
|
|
/* global variables */
|
|
|
|
|
int g_counter = 0;
|
|
|
|
|
|
|
|
|
|
/* functions */
|
|
|
|
|
int
|
|
|
|
|
main (void)
|
|
|
|
|
{
|
|
|
|
|
// Initialize the LEDs and Buttons
|
|
|
|
|
Led_init();
|
|
|
|
|
Taster_init();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int counter = 0;
|
|
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
|
|
|
|
// Run Task 1
|
|
|
|
|
task1();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Tast 1 (2021-10-21) */
|
|
|
|
|
void
|
|
|
|
|
task1 () {
|
|
|
|
|
_delay_ms(50);
|
|
|
|
|
|
|
|
|
|
/* Programmieren Sie ein Lauflicht. Nutzen Sie dazu die in „Led.h“ deklarierten
|
|
|
|
@ -37,22 +51,21 @@ int main(void)
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// Check if counter needs to be incremented
|
|
|
|
|
if (Taster1_get()) counter++;
|
|
|
|
|
if (Taster1_get()) g_counter++;
|
|
|
|
|
|
|
|
|
|
// Check if counter needs to be decremented
|
|
|
|
|
if (Taster2_get()) counter--;
|
|
|
|
|
if (Taster2_get()) g_counter--;
|
|
|
|
|
|
|
|
|
|
// Keep counter within boundaries (0-8)
|
|
|
|
|
counter = (counter + 9) % 9;
|
|
|
|
|
g_counter = (g_counter + 9) % 9;
|
|
|
|
|
|
|
|
|
|
// Set the LEDs according to the counter
|
|
|
|
|
counter >= 1 ? Led1_On() : Led1_Off();
|
|
|
|
|
counter >= 2 ? Led2_On() : Led2_Off();
|
|
|
|
|
counter >= 3 ? Led3_On() : Led3_Off();
|
|
|
|
|
counter >= 4 ? Led4_On() : Led4_Off();
|
|
|
|
|
counter >= 5 ? Led5_On() : Led5_Off();
|
|
|
|
|
counter >= 6 ? Led6_On() : Led6_Off();
|
|
|
|
|
counter >= 7 ? Led7_On() : Led7_Off();
|
|
|
|
|
counter >= 8 ? Led8_On() : Led8_Off();
|
|
|
|
|
}
|
|
|
|
|
g_counter >= 1 ? Led1_On() : Led1_Off();
|
|
|
|
|
g_counter >= 2 ? Led2_On() : Led2_Off();
|
|
|
|
|
g_counter >= 3 ? Led3_On() : Led3_Off();
|
|
|
|
|
g_counter >= 4 ? Led4_On() : Led4_Off();
|
|
|
|
|
g_counter >= 5 ? Led5_On() : Led5_Off();
|
|
|
|
|
g_counter >= 6 ? Led6_On() : Led6_Off();
|
|
|
|
|
g_counter >= 7 ? Led7_On() : Led7_Off();
|
|
|
|
|
g_counter >= 8 ? Led8_On() : Led8_Off();
|
|
|
|
|
}
|