Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define F_CPU 16000000UL
- #include <avr/io.h>
- #include <avr/interrupt.h>
- #include <avr/pgmspace.h>
- #include "lookup.dat"
- volatile int zaehlerstand = 0;
- void init (void)
- {
- DDRB |= (1<<DDB1) | (1<<DDB2) | (1<<DDB3);// RGB auf Output setzen
- TCCR1A |= (1<<WGM10) | (1<<COM1A1) | (1<<COM1B1); // 8-bit Phase Correct PWM Modus Timer 1, CTC
- TCCR1B |= (1<<CS11); // Prescaler 8
- TCCR2A |= (1<<WGM20) | (1<<COM2A1); //PWM Phase Correct Timer 2, CTC
- TCCR2B |= (1<<CS21);// Prescaler 8
- TCCR0B |= (1<<CS02) | (1<<CS00); //Prescaler 1024
- TCNT0 = 134; //Startwert
- TIMSK0 |= (1<<TOIE0); //Interrupt Lokal aktivieren
- sei(); //Global Interrupt aktivieren
- }
- int main (void)
- {
- init ();
- while (1)
- {
- //Rot LED
- OCR1B = 0;
- OCR2A = 0;
- OCR1A = 0;
- zaehlerstand = 0;
- while (zaehlerstand <= 255)
- {
- OCR1A = pgm_read_byte_near(lookup +zaehlerstand);
- }
- OCR1A = 0;
- //Warten 2s
- zaehlerstand = 0;
- while (zaehlerstand <= 255)
- {
- }
- //Grün LED
- zaehlerstand = 0;
- while (zaehlerstand <= 255)
- {
- OCR1B = pgm_read_byte_near(lookup +zaehlerstand);
- }
- OCR1B = 0;
- //Warten 2s
- zaehlerstand = 0;
- while (zaehlerstand <= 255)
- {
- }
- //Blaue LED
- zaehlerstand = 0;
- while (zaehlerstand <= 255)
- {
- OCR2A = pgm_read_byte_near(lookup +zaehlerstand);
- }
- OCR2A = 0;
- //Warten 2s
- zaehlerstand = 0;
- while (zaehlerstand <= 255)
- {
- }
- //Alle zusammen
- zaehlerstand = 0;
- while (zaehlerstand <=255)
- {
- OCR1A = pgm_read_byte_near(lookup +zaehlerstand);
- OCR1B = pgm_read_byte_near(lookup +zaehlerstand);
- OCR2A = pgm_read_byte_near(lookup +zaehlerstand);
- }
- zaehlerstand = 0;
- while (zaehlerstand <=255)
- {
- OCR1A = pgm_read_byte_near(lookup + 255 -zaehlerstand);
- OCR1B = pgm_read_byte_near(lookup + 255 -zaehlerstand);
- OCR2A = pgm_read_byte_near(lookup + 255 -zaehlerstand);
- }
- OCR1B = 0;
- OCR2A = 0;
- OCR1A = 0;
- //Warten 2s
- zaehlerstand = 0;
- while (zaehlerstand <= 255)
- {
- }
- }
- }
- ISR (TIMER0_OVF_vect)
- {
- TCNT0 = 134;
- zaehlerstand++;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement