RGB light with ardunio

RGB LIGHT WITH ARDUNIO


INTRODUCTION:

it is the most simplest connection .we can get different color including red, green,blue. 


THINGS REQUIRED:

  • RGB light.
  • ardunio(uno).
  • some jumper wire.

CODE:


int redpin=9;
int greenpin=10;
int bluepin=11;


void setup() {
  // put your setup code here, to run once:

pinMode(redpin,OUTPUT);
pinMode(greenpin,OUTPUT);
pinMode(bluepin,OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
setcolor(255,0,0);
delay(1000);
setcolor(0,255,0);
delay(1000);
setcolor(0,0,255);
delay(1000);
setcolor(255,255,255);
delay(1000);
setcolor(170,0,255);
delay(1000);
}
void setcolor(int redvalue,int greenvalue,int bluevalue){
  analogWrite(redpin,redvalue);
  analogWrite(greenpin,greenvalue);//to set the pmw which controls the brightness
  analogWrite(bluepin,bluevalue);
}



we have connect the red pin of RGB sensor any of the pin of ardunio in same way greeen and blue pin of  RGB sensor connect with any of the digital pin of  ardunio. write code that given above and upload it work.

Connection:


Comments

Popular Posts