Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- volatile uint8_t BRIGHTNESS_BUFFER[NUM_LEDS] = { 0 };
- volatile uint8_t current_led = 0;
- volatile uint8_t pwm_counter = 0;
- ISR(TCA0_OVF_vect) {
- static uint32_t lastCheck = 0;
- static uint32_t lastCheck2 = 0;
- static uint8_t rot = 0;
- if (countDown(&lastCheck2, 10)) {
- BRIGHTNESS_BUFFER[28] = BREATH[rot++];
- }
- if (countDown(&lastCheck, 300)) {
- for (uint8_t led = 0; led < NUM_LEDS; ++led) {
- if (led == 28) {
- } else if (random8() & random8() & 1) {
- BRIGHTNESS_BUFFER[led] = random8() >> 3;
- } else {
- BRIGHTNESS_BUFFER[led] = 0;
- }
- }
- }
- TCA0.SINGLE.INTFLAGS = TCA_SINGLE_OVF_bm; // Clear the interrupt flag
- }
- void loop() {
- resetLeds();
- if (pwm_counter < BRIGHTNESS_BUFFER[current_led]) {
- setLed(current_led);
- }
- delayMicroseconds(50);
- current_led++;
- if (current_led >= NUM_LEDS) {
- current_led = 0;
- }
- pwm_counter++;
- }
Advertisement
Add Comment
Please, Sign In to add comment