Devices & Components
ATtiny85
Software & Tools
Arduino IDE
Project description
Code
Demo Code For RGB using Attiny85
c_cpp
1#include <DigisparkRGB.h> 2/* 3 Digispark RGB 4 5 This example shows how to use soft PWM to fade 3 colors. 6 Note: This is only necessary for PB2 (pin 2) - Blue, as Red (pin 0) and Green (pin 1) as well as pin 4 support the standard Arduino analogWrite() function. 7 8 This example code is in the public domain. 9 */ 10byte RED = 0; 11byte BLUE = 2; 12byte GREEN = 1; 13byte COLORS[] = {RED, BLUE, GREEN}; 14 15// the setup routine runs once when you press reset: 16void setup() { 17 DigisparkRGBBegin(); 18} 19 20 21void loop () 22{ 23//direction: up = true, down = false 24boolean dir = true; 25int i = 0; 26 27while(1) 28{ 29fade(COLORS[i%3], dir); 30i++; 31dir = !dir; 32} 33} 34void fade(byte Led, boolean dir) 35{ 36int i; 37 38//if fading up 39if (dir) 40{ 41for (i = 0; i < 256; i++) 42{ 43DigisparkRGB(Led, i); 44DigisparkRGBDelay(25);//1); 45} 46} 47else 48{ 49for (i = 255; i >= 0; i--) 50{ 51DigisparkRGB(Led, i); 52DigisparkRGBDelay(25);//1); 53} 54} 55} 56 57 58
Downloadable files
Pinouts
Pinouts

Pinouts
Pinouts

Comments
Only logged in users can leave comments