intermediateChapter 37 of 4530 min

37. Extreme Bright Dual LEDs

Use PWM to control warm white (3000K) and cool white (6500K) separately; outcome: show warm white, then cool white, then mixed light, each about 2 s, repeat.

This lesson uses: Arduino UNO R3 board, TinkerBlock TK95 Extreme Bright Dual LEDs module, jumper wires (or breadboard). Use PWM to control warm white (3000K) and cool white (6500K) separately; outcome: show warm white, then cool white, then mixed light, each about 2 s, repeat.

1. Wiring

Connect TK95 Extreme Bright Dual LEDs to Arduino (each LED on a PWM pin):

  • GND → Arduino GND
  • VCC → Arduino 5V (it powers both LEDs; without it nothing lights)
  • 3000K → Arduino D5 (PWM, warm white)
  • 6500K → Arduino D3 (PWM, cool white)

TK95 wiring diagram

The drawing shows the warm wire on D2. D2 has no PWM on an Uno, so it can only switch the LED fully on or off: use D5.

2. New sketch

  1. Arduino IDE: File → New (or Ctrl/Cmd + N) to create a blank sketch
  2. Confirm board and port are selected (same as Lesson 01)
  3. Type the code below into the default setup() and loop() yourself

3. Program structure

Same as last lesson: two fixed blocks setup() and loop().

  • setup(): Tell the board “D5, D3 for LEDs (PWM)”, both LOW to start; start serial; runs once.
  • loop(): Keep repeating “warm on → cool on → both on (mixed) → repeat”.

Two PWM channels, one per LED; you’ll see warm, then cool, then both for mixed color temperature.

4. Code to write

Type the code below into setup() and loop() (do not copy-paste; typing it yourself helps you remember):

lesson37.ino
// Dual LEDs: warm D5, cool D3; PWM each; mix ratio = color temperature
// VCC -> 5V. D2 cannot do PWM on an Uno, so warm is on D5.
#define WARM_PIN 5   // 3000K warm white
#define COLD_PIN 3   // 6500K cool white

// On 5V an LED held fully on runs past its rating: stop at 170.
#define FULL 170

void setup() {
  pinMode(WARM_PIN, OUTPUT);   // D5 warm PWM
  digitalWrite(WARM_PIN, LOW);
  pinMode(COLD_PIN, OUTPUT);   // D3 cool PWM
  digitalWrite(COLD_PIN, LOW);
  Serial.begin(9600);
  Serial.println("Extreme bright dual LED program started");
}

void loop() {
  analogWrite(WARM_PIN, FULL);      // Warm only
  analogWrite(COLD_PIN, 0);
  Serial.println("Warm white");
  delay(2000);
  analogWrite(WARM_PIN, 0);         // Cool only
  analogWrite(COLD_PIN, FULL);
  Serial.println("Cool white");
  delay(2000);
  analogWrite(WARM_PIN, FULL / 2);  // Both half; mixed
  analogWrite(COLD_PIN, FULL / 2);
  Serial.println("Mixed");
  delay(2000);
}
View on GitHub · workshop/37-extreme-bright-dual-leds/arduino/lesson37/lesson37.ino @ v1.13

Program notes

Overall idea: Two LEDs on PWM pins; use analogWrite 0–255 for each. On 5V the sketch stops at 170 (FULL): held fully on at 255, these LEDs run a little past their rating. One channel at FULL = pure warm or pure cool; both on = mix; different ratios give different color temperature (more warm = yellower, more cool = bluer).

CodeIn this lesson
analogWrite(WARM_PIN, FULL)Warm at 170 of 255; 0 = off
analogWrite(COLD_PIN, FULL / 2)Cool at half; with warm = mixed
Color temperatureRatio of the two channels sets perceived color; try different values

5. Hands-on

  1. After entering the code, click Verify (✓) to compile
  2. Click Upload (→) to upload to the board
  3. Watch TK95: warm white, then cool white, then mixed, then repeat
  4. Try yourself: change the two brightness values to get different color temperatures

Expected result: As in the figure.

Extreme bright dual LED effect

Proceed to Lesson 38.

Edit this page — content/guides/tinkerblock-workshop/37-extreme-bright-dual-leds.mdx

Community

Questions about this product

See what other owners have asked, and read their solutions.

Ask a question ↗

Dual Bright LEDs

Loading discussions…

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse Projects and guides on the forum →