RGB LED With ATtiny85 Part 2
I’ve updated my script and removed the pot from my design, so that now it just fades between random colours on its own, using an LDR to tell if its dark enough to turn on or so light that it should turn itself off as you wouldn’t see the LED anyway:
// init vars
const int REDPIN = 1; // 85 leg 6
const int GREENPIN = 0; // 85 leg 5
const int BLUEPIN = 4; // 85 leg 3
const int LDR = 3; // 85 leg 2
const int THRESHOLD = 200;
int last_time;
int red;
int green;
int blue;
int current_red;
int current_green;
int current_blue;
void doFade(int pin, int &val, int ¤t_val)
{
// val and current_val are passed as references
// so modifying them will actually modify e.