In this tutorial we will automatically vary the light intensity of an RGB LED module with the Arduino.
Arduino UNO
The Arduino UNO is a microcontroller board based on the ATmega328P. It has 14 digital input/output pins, 6 analog inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP header, and a reset button. It is the most popular and widely used board among the Arduino boards.
The Arduino UNO can be programmed using the Arduino programming language, which is based on C++. It uses a simple and intuitive programming environment, making it easy for beginners to get started with microcontroller programming.
The Arduino UNO can be connected to various sensors and actuators to control different devices and perform different tasks. For example, it can be used to control motors, read data from sensors, display information on an LCD screen, and communicate with other devices via serial communication protocols such as I2C and SPI.
The Arduino UNO can also be powered by a USB cable or an external power supply, making it easy to use in a wide range of projects and applications. It’s compatible with a wide range of shields (expansion boards) that adds functionality to the board, such as Ethernet, WiFi, and Bluetooth, and it’s widely supported by a strong and active community, which provides a lot of tutorials, examples and libraries to help users to get the most of the board.
RGB LED module
An RGB LED module is a type of LED module that contains multiple light-emitting diodes (LEDs) of the colors red, green, and blue. These LEDs can be individually controlled to produce a wide range of colors by adjusting the intensity of each color. This allows for a wide range of visual effects and color options in electronic devices such as lighting fixtures, gaming peripherals, and displays. These RGB LED modules are controlled by microcontroller or driver IC and can be used in various projects like mood light, RGB LED strip lights, etc. These are widely used in various industry, home decoration and DIY projects
connecting wires
Connecting wires are used to connect various components in an electronic circuit. They allow for the transfer of electricity, data, or signals between different devices and components.
When connecting wires to an Arduino or other microcontroller, it is important to pay attention to the correct pinout. The pinout refers to the arrangement of pins on the microcontroller and the corresponding function of each pin. The Arduino pinout can be found in the documentation provided by the manufacturer, or in various resources available online.
Connect:
Here is the program that automatically varies the light intensity of an RGB LED with the Arduino.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
void setup(){ pinMode(0,OUTPUT); //sets the number 0 digital pin of the Arduino in output modepinMode(0,OUTPUT); //sets the number 1 digital pin of the Arduino in output modepinMode(0,OUTPUT); //sets the number 0 digital pin of the Arduino in output mode pinMode(1,OUTPUT); //sets the number 1 digital pin of the Arduino in output modepinMode(1,OUTPUT); //sets the number 1 digital pin of the Arduino in output modepinMode(1,OUTPUT); //sets the number 1 digital pin of the Arduino in output mode pinMode(2,OUTPUT); //sets the number 2 digital pin of the Arduino in output modepinMode(2,OUTPUT); //sets the number 1 digital pin of the Arduino in output modepinMode(2,OUTPUT); //sets the number 2 digital pin of the Arduino in output mode } void loop(){ //the LED module lights up in red and green digitalWrite(0,HIGH); digitalWrite(1,HIGH); digitalWrite(2,LOW); delay(2000); //lthe LED module lights up in red digitalWrite(0,HIGH); digitalWrite(1,LOW); digitalWrite(2,LOW); delay(2000); //the LED module lights up in red and blue digitalWrite(0,LOW); digitalWrite(1,HIGH); digitalWrite(2,LOW); delay(2000); //the LED module lights up in green digitalWrite(0,HIGH); digitalWrite(1,LOW); digitalWrite(2,HIGH); delay(2000); //the LED module lights up in red ,blue and green digitalWrite(0,HIGH); digitalWrite(1,HIGH); digitalWrite(2,HIGH); delay(2000); } |