all | audio | badgelife | breakout | clocks | displays | experiments | feather | handhelds | home automation | howto | LED art | misc | props | robots | sewing | software | tools | no_category

not so tunable-white light

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

Initially a project for me to work with MOSFETs controlled by an ESP board, but weak panels made me return to an attiny45 and an ULN2803s. And 10 lines of Arduino code. Man I'm lazy.

not so tunable-white light | code

2016-01-16 15:52:47
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);
}

not so tunable-white light | code

2016-01-16 15:52:47
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);
}