Interfacing the RGB LED with the Arduino

Procedure

  • Source
  • Target

NOTE: First make the connections, then move to code compilation.

1. Drag and drop the components in the workspace to create the circuit.

2. Connect the push button to the digital Pin 7(D7) which act as INPUT.

3. Attach the positive leg (the longer leg) of the LED to digital Pin 11 of the Arduino Uno, and the negative leg via the 220-ohm resistor to GND. The Pin D11 is taken as OUTPUT.

4. The 10kΩ resistor used as PULL-UP resistor and 220 Ω resistors is used to limit the current through the LED.

5. After connections click on the CHECK button to check the connections.

NOTE: Right click on the component to open the dialog box to edit the properties of the component.

6. For the code compiler:

  • Set the ledstate to “LOW” first.
  • Set the pinMode of ledPin as “OUTPUT”.
  • Set the pinMode of buttonPin as “INPUT”.
  • Set the button state as “HIGH”.

7. Now, click on COMPILE button to compile the code.

8. Press the push-button to control the ON state of LED.

9. Click on RESET button to reload the webpage