Gast
#2438406
Hallo liebe Mikrocontroller Team :) Und zwar hab ich folgendes Problem. Ich hab mir einen 3x3x3 LED Cube gebaut und er funktioniert auch soweit. Ich kann meine Programme ohne Probleme laufen lassen. Nun möchte ich aber mittels einem Taster (Interrupt) zwischen meinen Programmen hin und her schalten. Nur so wie ich das Versuche geht es nicht vllt könnt ihr mir ja weiterhelfen. Hier der Code: #include <avr/io.h> #include <util/delay.h> #include <avr/interrupt.h> #include <inttypes.h> uint8_t status; void delay_ms(uint16_t ms) { for(uint16_t t=0; t<=ms; t++) _delay_ms(1); } int main() { cli(); DDRD = 0b11110111; DDRC = 0xFF; DDRB = 0xFF; GIMSK = (1<<(INT1)); // Interrupt Freigeben MCUCR |= (1<<ISC11) | (1<<(ISC10)) ; // Interrupt löst bei steigender Flanke aus sei(); // Interrupt wird eingeschalet while (1) //Endlos { if (status==1) { void OB(); status=0; } if (status==2) { void ME(); status=0; } if (status==3) { void UE(); status=0; } } return 0; } ISR(INT1_vect) //Interruptvektor { status=1; } void OE () { PORTD &=~(1<< PD2); PORTD |=(1<< PD0); //Ebene 3 PORTB &=~(1<<PB3); PORTC |=(1<< PC5) ; // _delay_ms(200); PORTC &=~(1<< PC5) ; PORTC |=(1<< PC4) ; // _delay_ms(200); PORTC &=~(1<< PC4) ; PORTC |=(1<< PC3) ; // _delay_ms(200); PORTC &=~(1<< PC3) ; PORTC |=(1<< PC2) ; // _delay_ms(200); PORTC &=~(1<< PC2) ; PORTC |=(1<< PC1) ; // _delay_ms(200); PORTC &=~(1<< PC1); PORTC |=(1<< PC0) ; // _delay_ms(200); PORTC &=~(1<< PC0); PORTB |=(1<< PB5) ; // _delay_ms(200); PORTB &=~(1<< PB5); PORTB |=(1<< PB4) ; // _delay_ms(200); PORTB &=~(1<< PB4); PORTB |=(1<< PB3) ; // _delay_ms(200); } void ME () { PORTD &=~(1<< PD0); //Ebene 2 PORTD |=(1<< PD1); PORTB &=~(1<<PB3); PORTC |=(1<< PC5) ; // _delay_ms(200); PORTC &=~(1<< PC5) ; PORTC |=(1<< PC4) ; // _delay_ms(200); PORTC &=~(1<< PC4) ; PORTC |=(1<< PC3) ; // _delay_ms(200); PORTC &=~(1<< PC3) ; PORTC |=(1<< PC2) ; // _delay_ms(200); PORTC &=~(1<< PC2) ; PORTC |=(1<< PC1) ; // _delay_ms(200); PORTC &=~(1<< PC1); PORTC |=(1<< PC0) ; // _delay_ms(200); PORTC &=~(1<< PC0); PORTB |=(1<< PB5) ; // _delay_ms(200); PORTB &=~(1<< PB5); PORTB |=(1<< PB4) ; // _delay_ms(200); PORTB &=~(1<< PB4); PORTB |=(1<< PB3) ; // _delay_ms(200); } void UE () { PORTD &=~(1<< PD1); //Ebene 1 PORTD |=(1<< PD2); PORTB &=~(1<<PB3); PORTC |=(1<< PC5) ; // _delay_ms(200); PORTC &=~(1<< PC5) ; PORTC |=(1<< PC4) ; // _delay_ms(200); PORTC &=~(1<< PC4) ; PORTC |=(1<< PC3) ; // _delay_ms(200); PORTC &=~(1<< PC3) ; PORTC |=(1<< PC2) ; // _delay_ms(200); PORTC &=~(1<< PC2) ; PORTC |=(1<< PC1) ; // _delay_ms(200); PORTC &=~(1<< PC1); PORTC |=(1<< PC0) ; // _delay_ms(200); PORTC &=~(1<< PC0); PORTB |=(1<< PB5) ; // _delay_ms(200); PORTB &=~(1<< PB5); PORTB |=(1<< PB4) ; // _delay_ms(200); PORTB &=~(1<< PB4); PORTB |=(1<< PB3) ; // _delay_ms(200); } Danke im Vorraus :)