Arduino - RGB Led Control With POTENTIOMETERS

Published

Introduction: Arduino - RGB Led Control With POTENTIOMETERS

About: Hello world! I make simple & Advanced projects for people who want to learn programming and electronics. Most of my Instructables are about arduino and the wide range of sensors you can use with it. I ma...

Hello world! Today i made a little project which is fun for kids to learn Electronics and how to control a RGB led. We are using a Solderless breadboard. The complete Fritzing file + PCB Files are included in the next step.

PCB files.

With the PCB files you can make your own Printed Circuit Board!

You can send those files to a company or individual who produces PCB's, you can order them through fritzing to.

Another way to make your own PCB's is etchingHOW TO ETCH? <-click here to find out how.

Step 1: Schematic, Code, Parts List & PCB Files.

Simply wire everything like the schematic shows, upload the code and it should work!

Parts list.

  • arduino nano, (Arduino Uno will do to! or others.)
  • 3 Potentiometers
  • 3 x 1k Resistor
  • RGB Led Common Cathode, Or Common Anode. You can use the KY-016 RGB Led Module to
  • Breadboard
  • Jumper wires set MM

Common Anode & Common Cathode RGB leds explanation.

Check if you are using a Common Anode or Common Cathode RGB Led

If you led does not light up when connected to GND, Try connecting it to 5v.

Add common anode to 5v and Common Cathode to GND.
The longest pin on the RGB Led is the Cathode or Anode pin.

If it does not work on GND it is a Anode.

If it does not work on 5v it is a Cathode.

Share

    Recommendations

    • Woodworking Contest

      Woodworking Contest
    • Make it Move Contest

      Make it Move Contest
    • Casting Contest

      Casting Contest
    user

    We have a be nice policy.
    Please be positive and constructive.

    Tips

    Questions

    4 Comments

    for people who had a problem with the code. RGB_led_Control_with_POTENTIOMETERS.ino had a space before a _ i fixed it, no clue how that happend.

    /*

    Author: Danny van den Brande, Arduinosensors.nl. BlueCore Tech.

    NOTE:There is a difference in RGB Leds, Common Annode and Common Cathode

    Add common anode to 5v and Common Cathode to GND.

    The longest pin on the RGB Led is the Cathode or Annode pin.

    If it does not work on 5v it is a Annode.

    If it does not work on GND it is a Cathode.

    */

    int redPin = 9; //Pin for the red RGB led pin

    int greenPin = 10; //Pin for the green RGB led pin

    int bluePin = 11; //Pin for the blue RGB led pin

    int potPin_red = A2; //declare pin for the potentiometer for the red LED

    int potPin_green = A1; //declare pin for the potentiometer for the green LED

    int potPin_blue = A0; //declare pin for the potentiometer for the blue LED

    int readValue_red; //declare variable to store the read value from the potentiometer which controls the red LED

    int readValue_green; //declare variable to store the read value from the potentiometer which controls the green LED

    int readValue_blue; //declare variable to store the read value from the potentiometer which controls the blue LED

    int writeValue_red; //declare variable to send to the red LED

    int writeValue_green; //declare variable to send to the green LED

    int writeValue_blue; //declare variable to send to the blue LED

    void setup() {

    pinMode(potPin_red, INPUT); //set potentiometer for red LED as input

    pinMode(potPin_green, INPUT); //set potentiometer for green LED as input

    pinMode(potPin_blue, INPUT); //set potentiometer for blue LED as input

    pinMode(redPin,OUTPUT); //set pin for red LED as output

    pinMode(bluePin,OUTPUT); //set pin for green LED as output

    pinMode(greenPin, OUTPUT); //set pin for blue LED as output

    }

    void loop() {

    readValue_red = analogRead(potPin_red); //Read voltage from potentiometer to control red LED

    readValue_green = analogRead(potPin_green); //Read voltage from potentiometer to control green LED

    readValue_blue = analogRead(potPin_blue); //Read voltage from potentiometer to control blue LED

    writeValue_red = (255./1023.)*readValue_red; //Calculate the value to write on the red LED (add point to change to float point)

    writeValue_green = (255./1023.)*readValue_green; //Calculate the value to write on the green LED

    writeValue_blue = (255./1023.)*readValue_blue; ///Calculate the value to write on the blue LED

    analogWrite(redPin,writeValue_red); //write value to set the brightness of the red LED

    analogWrite(greenPin,writeValue_green); //write value to set the brightness of the green LED

    analogWrite(bluePin,writeValue_blue); //write value to set the brightness of the blue LED

    }