Project showcase
Weekend Project: Under-Desk Lighting

Weekend Project: Under-Desk Lighting © GPL3+

More LED strips everywhere.

  • 2,028 views
  • 0 comments
  • 3 respects

Components and supplies

About this project

Description

An LED strip under my desk does a light show with slowly fading colours. A rocker switch built into my desktop turns it on or off.

This was a quick project I put together over 5-6 hours. I wanted to have a little light show under my desk that I could somehow build into my desktop. I drilled a hole through my inch-thick deck for a rocker switch to control the power supplied to the device.

I had a little case that was collecting dust and finally made use of it! I also drilled holes for the power jack and LED strip pins. I based the schematic off my Bed Lighting project. PWM controls the three transistors to mix colours.

I used an Arduino Nano even though it was more than I really needed for a project this simple. The main reason I used it rather than just a micro was because of the USB jack built-in. I didn`t feel the need to put something in the case to control different routines, but being able to reprogram it in the future easily was a big desire.

Warning to anyone wanting to replicate something like this: make sure to disconnect the board from the power supply and LED strip before programming this. It isn`t good to have two power supplied connected to the same input. If the LED strip is connected, the USB could attempt to power the entire length of the LED strip, burning out the regulator on the Nano.

Code

current working codeArduino
// Scott Clandinin - 2017


#define REDPIN 5
#define GREENPIN 3
#define BLUEPIN 6
 
void setup() 
{
  pinMode(REDPIN, OUTPUT);
  pinMode(GREENPIN, OUTPUT);
  pinMode(BLUEPIN, OUTPUT);

  randomSeed(analogRead(0));  //set random seed off floating pin A0
  
  analogWrite(BLUEPIN, 255);
  delay(1000);
} 
 
void loop() 
{

  int routine;

  routine1();
//  routine = random(1,4);
//
//  switch(routine)
//  {
//    case 1:
//      routine1();
//      break;
//  
//    case 2:
//      routine2();
//      break;
//  
//    case 3:
//      routine3();
//      break;   
//      
//    case 4:
//      routine4();
//      break;   
//  }
  
 
 
}




//******************************************************
//                    fading colours
//******************************************************
void routine1()
{
  int r, g, b; 
  int FADESPEED = 10;     // make this higher to slow down
  
 // fade from blue to violet
  for (r = 0; r < 255; r++) 
  { 
    analogWrite(REDPIN, r);
    delay(FADESPEED);
  } 
  // fade from violet to red
  for  (b = 255; b > 0; b--)
  { 
    analogWrite(BLUEPIN, b);
    delay(FADESPEED);
  } 
  // fade from red to yellow
  for (g = 0; g < 255; g++) 
  { 
    analogWrite(GREENPIN, g);
    delay(FADESPEED);
  } 
  // fade from yellow to green
  for (r = 255; r > 0; r--) 
  { 
    analogWrite(REDPIN, r);
    delay(FADESPEED);
  } 
  // fade from green to teal
  for (b = 0; b < 255; b++) 
  { 
    analogWrite(BLUEPIN, b);
    delay(FADESPEED);
  }
  // fade from teal to blue
  for (g = 255; g > 0; g--) 
  { 
    analogWrite(GREENPIN, g);
    delay(FADESPEED);
  }     
  
}


//******************************************************
//                    changing colours
//******************************************************
void routine2()
{
  int r, g, b; 
  
  
  analogWrite(REDPIN, 255);     //RED
  analogWrite(GREENPIN, 0);
  analogWrite(BLUEPIN, 0);
  delay(1000);
  
  analogWrite(REDPIN, 200);     //yellow
  analogWrite(GREENPIN, 255);
  analogWrite(BLUEPIN, 0);
  delay(1000);

  analogWrite(REDPIN, 255);     //orange
  analogWrite(GREENPIN, 255);
  analogWrite(BLUEPIN, 0);
  delay(1000);

  analogWrite(REDPIN, 0);     //green
  analogWrite(GREENPIN, 255);
  analogWrite(BLUEPIN, 0);
  delay(1000);
  
  analogWrite(REDPIN, 25);     //teal
  analogWrite(GREENPIN, 255);
  analogWrite(BLUEPIN, 255);
  delay(1000);
  
  analogWrite(REDPIN, 0);     //blue
  analogWrite(GREENPIN, 0);
  analogWrite(BLUEPIN, 255);
  delay(1000);
  
  analogWrite(REDPIN, 255);     //purple
  analogWrite(GREENPIN, 0);
  analogWrite(BLUEPIN, 255);
  delay(1000);

  analogWrite(REDPIN, 255);     //pink
  analogWrite(GREENPIN, 50);
  analogWrite(BLUEPIN, 50);
  delay(1000);
  
}


//******************************************************
//                    fading blue
//******************************************************
void routine3()
{
  int r, g, b; 
  int FADESPEED = 20;      // make this higher to slow down

  // fade to blue
  for  (b = 0; b < 255; b++)
  { 
    analogWrite(BLUEPIN, b);
    delay(FADESPEED);
  } 

  // fade out blue
  for  (b = 255; b > 0; b--)
  { 
    analogWrite(BLUEPIN, b);
    delay(FADESPEED);
  } 
}


//******************************************************
//                    strobe purple
//******************************************************
void routine4()
{  

  analogWrite(REDPIN, 255);     //purple
  analogWrite(GREENPIN, 0);
  analogWrite(BLUEPIN, 255);
  delay(100);

  analogWrite(REDPIN, 0);     //off
  analogWrite(GREENPIN, 0);
  analogWrite(BLUEPIN, 0);
  delay(100);
}

Schematics

schematic
Schematic 1pelqif1k4

Comments

Similar projects you might like

Add Animated (Marquee) Lighting to Your Projects

Project tutorial by ericBcreator

  • 1,476 views
  • 4 comments
  • 17 respects

Solar Powered, Cellar Lighting Arduino Control

Project in progress by TJ Blevins

  • 1,342 views
  • 0 comments
  • 3 respects

Automated LED Lighting for Planted Aquarium

Project showcase by indoorgeek

  • 2,127 views
  • 2 comments
  • 6 respects

Kitchen Working Area Automatic Lighting on Arduino

Project tutorial by Vadim

  • 1,530 views
  • 2 comments
  • 4 respects

Aquarium Ambience Lighting (LED) Control

Project showcase by randtekk

  • 814 views
  • 1 comment
  • 2 respects

SMART Home LED Lighting System and More

Project in progress by Joey Pongallo

  • 5,948 views
  • 4 comments
  • 13 respects
Add projectSign up / Login