Project tutorial
Night Lamp

Night Lamp

Lights are the most important tool to create the mood and ambiance of a living space. Here is multicolored night lamp build using Arduino.

  • 1,303 views
  • 0 comments
  • 4 respects

Components and supplies

Ph a000066 iso (1) ztbmubhmho
Arduino UNO
×1
09264 1
RGB Diffused Common Cathode
×1
General purpose PCB board
×1
multi stand wire
×1
Mfr 25frf52 1k sml
Resistor 1k ohm
×1

Necessary tools and machines

Apps and online services

About this project

Code

RGB led Light ConrolArduino
Here you will find the 8 color generating function.
#define r1 0
#define g1 1
#define b1 2

#define r2 3
#define g2 4
#define b2 5

#define r3 6
#define g3 7
#define b3 8

#define r4 9
#define g4 10
#define b4 11

void red()
{
  digitalWrite(r1,HIGH);
  digitalWrite(r2,HIGH);
  digitalWrite(r3,HIGH);
  digitalWrite(r4,HIGH);

  digitalWrite(g1,LOW);
  digitalWrite(g2,LOW);
  digitalWrite(g3,LOW);
  digitalWrite(g4,LOW);

  digitalWrite(b1,LOW);
  digitalWrite(b2,LOW);
  digitalWrite(b3,LOW);
  digitalWrite(b4,LOW);
}

void green()
{
  digitalWrite(r1,LOW);
  digitalWrite(r2,LOW);
  digitalWrite(r3,LOW);
  digitalWrite(r4,LOW);

  digitalWrite(g1,HIGH);
  digitalWrite(g2,HIGH);
  digitalWrite(g3,HIGH);
  digitalWrite(g4,HIGH);

  digitalWrite(b1,LOW);
  digitalWrite(b2,LOW);
  digitalWrite(b3,LOW);
  digitalWrite(b4,LOW);
}

void blue()
{
  digitalWrite(r1,LOW);
  digitalWrite(r2,LOW);
  digitalWrite(r3,LOW);
  digitalWrite(r4,LOW);

  digitalWrite(g1,LOW);
  digitalWrite(g2,LOW);
  digitalWrite(g3,LOW);
  digitalWrite(g4,LOW);

  digitalWrite(b1,HIGH);
  digitalWrite(b2,HIGH);
  digitalWrite(b3,HIGH);
  digitalWrite(b4,HIGH);
}

void yellow()
{
  digitalWrite(r1,HIGH);
  digitalWrite(r2,HIGH);
  digitalWrite(r3,HIGH);
  digitalWrite(r4,HIGH);

  digitalWrite(g1,HIGH);
  digitalWrite(g2,HIGH);
  digitalWrite(g3,HIGH);
  digitalWrite(g4,HIGH);

  digitalWrite(b1,LOW);
  digitalWrite(b2,LOW);
  digitalWrite(b3,LOW);
  digitalWrite(b4,LOW);
}

void cyan()
{
  digitalWrite(r1,LOW);
  digitalWrite(r2,LOW);
  digitalWrite(r3,LOW);
  digitalWrite(r4,LOW);

  digitalWrite(g1,HIGH);
  digitalWrite(g2,HIGH);
  digitalWrite(g3,HIGH);
  digitalWrite(g4,HIGH);

  digitalWrite(b1,HIGH);
  digitalWrite(b2,HIGH);
  digitalWrite(b3,HIGH);
  digitalWrite(b4,HIGH);
}

void magnetica()
{
  digitalWrite(r1,HIGH);
  digitalWrite(r2,HIGH);
  digitalWrite(r3,HIGH);
  digitalWrite(r4,HIGH);

  digitalWrite(g1,LOW);
  digitalWrite(g2,LOW);
  digitalWrite(g3,LOW);
  digitalWrite(g4,LOW);

  digitalWrite(b1,HIGH);
  digitalWrite(b2,HIGH);
  digitalWrite(b3,HIGH);
  digitalWrite(b4,HIGH);
}

void white()
{
  digitalWrite(r1,HIGH);
  digitalWrite(r2,HIGH);
  digitalWrite(r3,HIGH);
  digitalWrite(r4,HIGH);

  digitalWrite(g1,HIGH);
  digitalWrite(g2,HIGH);
  digitalWrite(g3,HIGH);
  digitalWrite(g4,HIGH);

  digitalWrite(b1,HIGH);
  digitalWrite(b2,HIGH);
  digitalWrite(b3,HIGH);
  digitalWrite(b4,HIGH);
}

void setup() {
  // put your setup code here, to run once:
 pinMode(0,OUTPUT);
 pinMode(1,OUTPUT);
 pinMode(2,OUTPUT);
 pinMode(3,OUTPUT);
 pinMode(4,OUTPUT);
 pinMode(5,OUTPUT);
 pinMode(6,OUTPUT);
 pinMode(7,OUTPUT);
 pinMode(8,OUTPUT);
 pinMode(9,OUTPUT);
 pinMode(10,OUTPUT);
 pinMode(11,OUTPUT);
 pinMode(12,OUTPUT);
 
}

void loop() {
 red();
 delay(1000);
 green();
 delay(1000);
 blue();
 delay(1000);
 yellow();
 delay(1000);
 cyan();
 delay(1000);
 magnetica();
 delay(1000);
 white();
 delay(1000);
}

Schematics

rgb led connection with arduino
Its just basic diagram.
Uploads2ftmp2f8827ea28 bc8d 4378 9a0e d5c46c4c93272fblob vjqsteunir blob ps7pgzq0j5

Comments

Similar projects you might like

Multi-Source Controlled USB Lamp

Project tutorial by Amal Mathew

  • 6,712 views
  • 2 comments
  • 21 respects

Motion Activated Night Light

Project tutorial by Haziq Afandi

  • 10,628 views
  • 3 comments
  • 8 respects

Night Lamp Using Arduino & Epoxy Resin

Project tutorial by TheTNR

  • 3,498 views
  • 0 comments
  • 12 respects

RFID Desk Lamp

Project tutorial by Kutluhan Aktar

  • 4,808 views
  • 0 comments
  • 10 respects

RobotGeek PIR Motion Sensor Night Light

Project tutorial by RobotGeek Projects Team

  • 4,235 views
  • 1 comment
  • 8 respects
Add projectSign up / Login