/* Four RGB LEDs David Johnson-Davies - www.technoblogy.com - 17th May 2016 ATtiny85 @ 8 MHz (internal oscillator; BOD disabled) CC BY 4.0 Licensed under a Creative Commons Attribution 4.0 International license: http://creativecommons.org/licenses/by/4.0/ */ // Colour of each LED; hex digits represent GBR volatile int Buffer[4] = { 0x000, 0x000, 0x000, 0x000 }; // Display multiplexer ********************************************** void DisplaySetup () { // Set up Timer/Counter1 to multiplex the display TCCR1 = 1< 78Hz TIMSK = TIMSK | 1<>2; int rgb = Buffer[led]; int r = rgb & 0x0F; int b = rgb>>4 & 0x0F; int g = rgb>>8 & 0x0F; int bits = (count < r) | (count < b)<<1 | (count < g)<<2; bits = bits + (bits & 0x07< 15) y = 31 - y; return max(y, 0); } int green (int x) { return red(x + 32); } int blue (int x) { return red(x + 64); } void loop () { for (int i=0; i<4; i++) { Buffer[i] = green(Step + i*12)<<8 | blue(Step + i*12)<<4 | red(Step + i*12); } Step++; delay(200); }