Hello everyone'
Today i am gone show you how to build this RGB light with help of Arduino and RGB strip(WS2122b).this project id for photography if you want light effect in videos and photo than this will help you to add ambient light or light effect to your photo or video.
So,Let,s make it
Components
Arduino nano x 1
Push Button x 3
Toggle switch x 1
WS2812b LED strip (as per your requirement)
Circuit Diagram
here is the circuit Diagram of this project
Source code
#include <SoftwareSerial.h>
#include <FastLED.h>
#define LED_PIN 3
#define NUM_LEDS 16
#define UP 4
#define DOWN 6
#define CH 7
#define M 8
CRGB leds[NUM_LEDS];
int R =0;
int G =0;
int B =0;
int val = 0;
int val1 = 0;
void setup()
{
pinMode(UP,INPUT);
pinMode(DOWN,INPUT);
pinMode(CH,INPUT);
FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
Serial.begin(9600);
Serial.print("ready");
}
void loop()
{
int mode = digitalRead(M);
if (mode == LOW)
{
int A = digitalRead(UP);
int B = digitalRead(DOWN);
if (A==LOW)
{
val = val + 1;
delay(500);
if (val == 10){
val=0;
}
}
else if (B==LOW){
val = val - 1;
delay(500);
if (val == 0){
val=10;
}
}
if (val == 1)
{
int i =0;
for (i=0;i<16;i++)
{
leds[i] = CRGB(250,0, 0);
FastLED.show();
}
}
else if (val == 2)
{
int i =0;
for (i=0;i<16;i++)
{
leds[i] = CRGB(0,250, 0);
FastLED.show();
}
}
else if (val == 3)
{
int i =0;
for (i=0;i<16;i++)
{
leds[i] = CRGB(0,0, 250);
FastLED.show();
}
}
else if (val == 4)
{
int i =0;
for (i=0;i<16;i++)
{
leds[i] = CRGB(250,250, 0);
FastLED.show();
}
}
else if (val == 5)
{
int i =0;
for (i=0;i<16;i++)
{
leds[i] = CRGB(250,0, 250);
FastLED.show();
}
}
else if (val == 6){
int i =0;
for (i=0;i<16;i++)
{
leds[i] = CRGB(0,250, 250);
FastLED.show();
}
}
else if (val == 7){
int i = 0;
for (i=0;i<16;i++)
{
leds[i] = CRGB(0,125, 250);
FastLED.show();
}
}
else if (val == 8)
{
int i = 0;
for (i=0;i<16;i++)
{
leds[i] = CRGB(125, 250,0);
FastLED.show();
}
}
}
else if (mode == HIGH){
int colour = digitalRead(CH);
if (colour == LOW)
{
val1= val1+1;
Serial.print(val1);
delay(500);
int i =0;
for (i=0;i<16;i++)
{
leds[i] = CRGB(0,0,0);
FastLED.show();
}
}
if (val1 == 1){
int A1 = digitalRead(UP);
int C1 = digitalRead(DOWN);
if (A1 == LOW)
{
R = R+1;
if (R == 251)
{
R = 1;}
delay(100);
}
else if (C1 == LOW)
{
R = R-1;
if (R == 0)
{
R = 250;}
delay(100);
}
int i =0;
for (i=0;i<16;i++)
{
leds[i] = CRGB(R,G,B);
FastLED.show();
}
}
if (val1 == 2){
int A1 = digitalRead(UP);
int C1 = digitalRead(DOWN);
if (A1 == LOW)
{
G = G+1;
if (G == 251)
{
G = 1;}
Serial.print(G);
delay(50);
}
else if (C1 == LOW)
{
G = G-1;
if (G == 0)
{
G = 250;}
delay(50);
}
int i =0;
for (i=0;i<16;i++)
{
leds[i] = CRGB(R,G,B);
FastLED.show();
}
}
if (val1 == 3){
int A1 = digitalRead(UP);
int C1 = digitalRead(DOWN);
if (A1 == LOW)
{
B = B+1;
if (B == 251)
{
B = 1;}
delay(50);
}
else if (C1 == LOW)
{
B = B-1;
if (B == 0)
{
B = 250;}
delay(50);
}
int i =0;
for (i=0;i<16 ;i++)
{
leds[i] = CRGB(R,G,B);
FastLED.show();
}
}
if (val1==4)
{
val1= 1;
}
}
}
Drawing
Working
Its working is simple its as a toggle switch which is use to switch between preset mode or manual mode. in preset mode their are preset color ,their are 10 preset (you can use you can add more color by editing the code)
In manual mode you can make your color by adjusting the brightness of the R-G-B light individually
that is relay simple
Video
for video build log https://youtu.be/6YS-u-xj3eY
Comments
Post a Comment