1 | #include <avr/io.h>
|
2 | #define F_CPU 8000000UL // 8 MHz
|
3 | #include <util/delay.h>
|
4 | #include "messen.h"
|
5 |
|
6 |
|
7 | int main(void)
|
8 | {
|
9 | uint16_t Mittelwert = 0;
|
10 |
|
11 | DDRD = DDRD|(1<<PD0)|(1<<PD1)|(1<<PD2)|(1<<PD3)|(1<<PD4)|(1<<PD5)|(1<<PD6)|(1<<PD7); //alle Pins vom PORTD sind jetzt Ausgänge
|
12 | DDRC = DDRC|(1<<PC3); //Pin PC3 ist jetzt Ausgang
|
13 | DDRB = DDRB|(1<<PB0)|(1<<PB6)|(1<<PB7); //Pins PB0, PB7, PB7 sind jetzt Ausgänge
|
14 |
|
15 | DDRC = DDRC&~(1<<PC1); //Pin PC1 ist jetzt als Eingang für das analoge Signal (also ADC1) konfiguriert
|
16 |
|
17 |
|
18 | while(1)
|
19 | {
|
20 | Mittelwert = ADC_Routine (1); // Parameterübergabe zur ADC-Kanalauswahl
|
21 |
|
22 | if (Mittelwert > 0) PORTC |= _BV(PC3); else PORTC &= ~_BV(PC3);
|
23 | if (Mittelwert > 26) PORTD |= _BV(PD0); else PORTD &= ~_BV(PD0);
|
24 | if (Mittelwert > 52) PORTD |= _BV(PD1); else PORTD &= ~_BV(PD1);
|
25 | if (Mittelwert > 77) PORTD |= _BV(PD2); else PORTD &= ~_BV(PD2);
|
26 | if (Mittelwert > 103) PORTD |= _BV(PD3); else PORTD &= ~_BV(PD3);
|
27 | if (Mittelwert > 128) PORTD |= _BV(PD4); else PORTD &= ~_BV(PD4);
|
28 | if (Mittelwert > 154) PORTD |= _BV(PD5); else PORTD &= ~_BV(PD5);
|
29 | if (Mittelwert > 800) PORTD |= _BV(PD6); else PORTD &= ~_BV(PD6);
|
30 | if (Mittelwert > 900) PORTD |= _BV(PD7); else PORTD &= ~_BV(PD7);
|
31 | if (Mittelwert > 1000) PORTB |= _BV(PB0); else PORTB &= ~_BV(PB0);
|
32 |
|
33 | }
|
34 | return(0);
|
35 |
|
36 | }
|