Close

code

A project log for not so tunable-white light

dimming warm-white and cold-white LED panels with an Attiny45

davedarkodavedarko 01/16/2016 at 14:520 Comments
int wwhite = 0;
int cwhite = 1;
int ain = A1;

void setup() 
{
  pinMode(cwhite, OUTPUT);
  pinMode(wwhite, OUTPUT);
  pinMode(ain, INPUT);
}

void loop() 
{
  int val = analogRead(ain);
  val = map(val, 0, 1023, 0, 255);
  analogWrite(wwhite, val);
  analogWrite(cwhite, 255-val);
}

Discussions