Arnov Sharma
Published © MIT

PICO Studio Light

Made a studio light that has warm, cool, and RGB LEDs all driven through a custom PICO driver circuit.

BeginnerFull instructions provided1,668
PICO Studio Light

Things used in this project

Hardware components

Raspberry Pi Pico 2
Raspberry Pi Pico 2
×1
ssd1306 oled display
×1

Software apps and online services

Fusion
Autodesk Fusion
Arduino IDE
Arduino IDE

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)

Story

Read more

Custom parts and enclosures

Fusion360File

Schematics

SCH 01

SCH 02

Code

code

C/C++
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <FastLED.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
#define SCREEN_ADDRESS 0x3C // Define the I2C address for the SSD1306 OLED
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

// Define the number of LEDs and data pin for WS2812B
#define NUM_LEDS 1
#define WS2812B_PIN 6
CRGB leds[NUM_LEDS];

// Define the GPIO pins for other LEDs
#define WARM_WHITE_PIN 2
#define COOL_WHITE_PIN 3

// Define the GPIO pins for buttons
#define WARM_WHITE_BUTTON 11
#define COOL_WHITE_BUTTON 12
#define RED_BUTTON 13
#define GREEN_BUTTON 14
#define BLUE_BUTTON 15

// Define brightness levels
#define BRIGHTNESS_LEVELS 5
int warmWhiteBrightness = 0;
int coolWhiteBrightness = 0;

// Keep track of button states
int lastWarmWhiteButtonState = HIGH;
int lastCoolWhiteButtonState = HIGH;

// RGB values
int rValue = 0;
int gValue = 0;
int bValue = 0;

void setup() {
  // Initialize FastLED
  FastLED.addLeds<NEOPIXEL, WS2812B_PIN>(leds, NUM_LEDS);

  // Initialize OLED display
  if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;);
  }
  display.display();
  delay(2000);
  display.clearDisplay();

  // Set other LED pins as OUTPUT
  pinMode(WARM_WHITE_PIN, OUTPUT);
  pinMode(COOL_WHITE_PIN, OUTPUT);
  
  // Set button pins as INPUT
  pinMode(WARM_WHITE_BUTTON, INPUT_PULLUP);
  pinMode(COOL_WHITE_BUTTON, INPUT_PULLUP);
  pinMode(RED_BUTTON, INPUT_PULLUP);
  pinMode(GREEN_BUTTON, INPUT_PULLUP);
  pinMode(BLUE_BUTTON, INPUT_PULLUP);
}

void loop() {
  // Read the state of each button
  int warmWhiteState = digitalRead(WARM_WHITE_BUTTON);
  int coolWhiteState = digitalRead(COOL_WHITE_BUTTON);
  int redState = digitalRead(RED_BUTTON);
  int greenState = digitalRead(GREEN_BUTTON);
  int blueState = digitalRead(BLUE_BUTTON);

  // Check for warm white button press
  if (warmWhiteState == LOW && lastWarmWhiteButtonState == HIGH) {
    warmWhiteBrightness = (warmWhiteBrightness + 1) % BRIGHTNESS_LEVELS;
    analogWrite(WARM_WHITE_PIN, warmWhiteBrightness * 255 / (BRIGHTNESS_LEVELS - 1));
  }
  lastWarmWhiteButtonState = warmWhiteState;

  // Check for cool white button press
  if (coolWhiteState == LOW && lastCoolWhiteButtonState == HIGH) {
    coolWhiteBrightness = (coolWhiteBrightness + 1) % BRIGHTNESS_LEVELS;
    analogWrite(COOL_WHITE_PIN, coolWhiteBrightness * 255 / (BRIGHTNESS_LEVELS - 1));
  }
  lastCoolWhiteButtonState = coolWhiteState;

  // Control WS2812B RGB LED and update RGB values
  if (redState == LOW) {
    rValue = 255; gValue = 0; bValue = 0;
    leds[0] = CRGB::Red;
    FastLED.show();
  } else if (greenState == LOW) {
    rValue = 0; gValue = 255; bValue = 0;
    leds[0] = CRGB::Green;
    FastLED.show();
  } else if (blueState == LOW) {
    rValue = 0; gValue = 0; bValue = 255;
    leds[0] = CRGB::Blue;
    FastLED.show();
  } else {
    rValue = 0; gValue = 0; bValue = 0;
    leds[0] = CRGB::Black; // Turn off RGB LED when no buttons are pressed
    FastLED.show();
  }

  // Update OLED display
  display.clearDisplay();
  
  // Display RGB values
  display.setTextSize(1);
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(0, 0);
  display.println(F("RGB VALUES"));
  display.setCursor(0, 10);
  display.print(F("R = ")); display.println(rValue);
  display.setCursor(0, 20);
  display.print(F("G = ")); display.println(gValue);
  display.setCursor(0, 30);
  display.print(F("B = ")); display.println(bValue);

  // Display Cool White brightness in equal-sized box
  display.setCursor(64, 10);
  display.println(F("COOL WHITE"));
  display.setCursor(64, 20);
  display.print(F(coolWhiteBrightness * 25)); display.println(F("%"));

  // Display Warm White brightness in equal-sized box
  display.setCursor(64, 40);
  display.println(F("WARM WHITE"));
  display.setCursor(64, 50);
  display.print(F(warmWhiteBrightness * 25)); display.println(F("%"));

  display.display();
}

Credits

Arnov Sharma
333 projects • 339 followers
Just your average MAKER
Contact

Comments

Please log in or sign up to comment.