The RGB Arduino used 3 LED basic colors red, green and blue. 3 colors used RGB and every cathode of every Led Could be Comman and every anode emit different color Provide like red led Emit Provide RED Color , green led Emit Provide GREEN Color and blue led Emit Provide BLUE Color.

Code

// These constants won't change Similar as Define 
const int BPin = A0;
const int GPin = A1; 
const int RPin = A2;
// Variable
int Rcolor=0;
int Gcolor=0;
int Bcolor=0;

void setup() {
  // initialize serial communications at 9600 bps:
  Serial.begin(9600);
}

void loop() {
  //mapping 
  Rcolor = map(analogRead(RPin), 0, 1023, 0, 255);
  Gcolor = map(analogRead(GPin), 0, 1023, 0, 255);
  Bcolor = map(analogRead(BPin), 0, 1023, 0, 255);
  // print the results to the Serial Monitor:
  Serial.print("R = ");
  Serial.print(Rcolor);
  Serial.print("\t G = ");
  Serial.print(Gcolor);
  Serial.print("\t B = ");
  Serial.println(Bcolor);
  analogWrite(6,Bcolor);
  analogWrite(5,Gcolor);
  analogWrite(3,Rcolor);  
  delay(100);//delay
}
(Visited 463 times, 1 visits today)
R-G-B LEDs Arduino Controlled by Potentiometer
Share with Friends :
Tagged on:     

Er. Arvind Ahir

Im Er. Arvind Ahir Skills Web Developer in Php, Networking, Arduino . Education 10th : KV Suranussi Jal. (2010-12) Diploma in CSE : Mehr Chand PolyTechnic Jal. (2012-15) B.Tech CSE : CT INSTITUTE OF TECHNOLOGY & RESEARCH, JALANDHAR (2015-19)

Leave a Reply

Your email address will not be published. Required fields are marked *