23 lines
1.0 KiB
C
23 lines
1.0 KiB
C
#include "keys.h"
|
|
|
|
|
|
void init(){
|
|
DDRD = 0xff; // Data direction register D (D0 -> D6) as output
|
|
// PORTD = 0xff; // setting bit for 7-segment show 0
|
|
// => spielt keine Rolle, wird von der while Schleife übernommen
|
|
|
|
DDRB = 0x01; // Data direction register B (B0) as output and DDRB (B1, B2) as input
|
|
PORTB |= (1 << PINB1) | (1 << PINB2) ; // setting bit for teens and SW1-2
|
|
// PINB=0 => start with LED3 (Einer)
|
|
|
|
// mit unserem Atmega nicht möglich, da keine PCINT8_vect und PCINT9_vect vorhanden
|
|
// DDRC = 0x00; // Data direction register C as input for SW1 and SW2
|
|
// PORTC |= (1<<PINC0) | (1<<PINC1); // settings pins for SW1 -> PINC0 and SW2 -> PINC1
|
|
|
|
cli(); // clear global interrupt flag: interrupts will be immediately disabled
|
|
PCICR |= 0x01; // Pin Change Interrupt Control Register: turn on PortB
|
|
PCMSK0 |= (1 << PINB1) | (1 << PINB2); // trigger interrupt when SW1 or SW2 is pressed
|
|
sei(); // set global interrupt enable
|
|
}
|
|
|