Tag Archives: led

ESP8266 IoT Based RGB LED Strip Controller

In this project we are making WiFi based RGB LED Strip Controller using ESP8266 and Arduino IDE. First we make basic RGB LED Controller using NodeMCU to understand How to control RGB LED colors using PWM?. Then we make little advanced RGB LED Strip controller with easy to use color pallet selection user interface as shown below.

NodeMCU RGB LED Control

Continue reading ESP8266 IoT Based RGB LED Strip Controller

ESP8266 Arduino WiFi Web Server LED on off control

In this tutorial, I am going to tell you about controlling LED using web server over WiFi using ESP8266 module or NodeMCU. So let’s start. In this tutorial we are using onboard LED of NodeMCU. If you are using different hardware you can connect led to GPIO2 or make changes in code as per your connection.

There are many ways to control LED over WiFi. We will go from basic to advance method of controlling LED using WiFi.

Continue reading ESP8266 Arduino WiFi Web Server LED on off control

ESP32 LED Blink Example

ESP32 is a new IoT device comes with Dual core CPU, WiFi, Bluetooth, In this tutorial we start with ESP32 Simple LED Blink Example. For software setup with arduino IDE read this.

ESP32 DevKit V1 comes with on board red LED which is connected to GPIO2 same as ESP8266 blink example.

Steps to Make LED Blink

Step 1: Connect Board to Laptop

ESP32 LED Blink Example

Step 2: ESP32 LED Blink Example Code

Upload this program to ESP32. Select boar ESP32 DEV Module from Tools >> Boards menu, then select appropriate com port. Upload the below program.

/*
 * https://circuits4you.com
 * ESP32 LED Blink Example
 * Board ESP23 DEVKIT V1
 * 
 * ON Board LED GPIO 2
 */

#define LED 2

void setup() {
  // Set pin mode
  pinMode(LED,OUTPUT);
}

void loop() {
  delay(500);
  digitalWrite(LED,HIGH);
  delay(500);
  digitalWrite(LED,LOW);
}

Step 3: Testing

After uploading program you will find on board RED LED will start Blinking.

 

RGB LED Interfacing with Arduino

In some cases you need to display a static text with different colors, for this purpose you can use RGB LED Strips. In this tutorial we will learn how to interface RGB LED strip with arduino and drive it using ULN2003.

rgb-led-strip

This is a basic tutorial for using Common Anode RGB LED Strip, PWM, and switch. By the end, you will have single switch to control colors of the LED strip. Connect the LED’s anode lead to +12V and connect the 3 RGB cathode leads to digital pins 9, 10, 11 through ULN2003 respectively.

RGB LED Strip Pin out
RGB LED Strip Pin out

RGB LED Strip Connections with Arduino

To drive complete RGB LED Strip we have used ULN2003 as a driver circuit, LED strip works at 12V. You can combine ULN2003 driver outputs to get more current.

RGB LED Arduino Interfacing Circuit
RGB LED Arduino Interfacing Circuit

Arduino Code for RGB LED Color Control

//=========================================================================
//         RGB LED Color Control
//         circuits4you.com
//=========================================================================
// constants won't change. They're used here to 
// set pin numbers:
const int buttonPin = 7;     // the number of the pushbutton pin
const int BLUEledPin =  11;      // LED pin
const int REDledPin =  10;      // LED pin
const int GREENledPin =  9;      // LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status
int color=0;
//=========================================================================
//              SETUP
//=========================================================================
void setup() {
  // initialize the LED pin as an output:
  pinMode(BLUEledPin, OUTPUT);  
  pinMode(REDledPin, OUTPUT);
  pinMode(GREENledPin, OUTPUT);
  
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);     
  digitalWrite(buttonPin, HIGH); //Activate internal pull up for switch
}
//=========================================================================
//                         LOOP
//=========================================================================
void loop(){
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == LOW) {     
    delay(300);
    color++;
    if(color>10)
    {color=0;}
  } 
  
  //Set different color values refer HTML Color codes
  switch (color)
  {
    case 0:
      SetColor(255,0,0);
    break;
    case 1:
      SetColor(255,255,0);
    break;
    case 2:
      SetColor(0,0,255);
    break;
    case 3:
      SetColor(128,128,20);
    break;
    case 4:
      SetColor(0,255,255);
    break;
    case 5:
      SetColor(55,100,100);
    break;
    case 6:
      SetColor(0x00,0xA8,0xA9);
    break;
    case 7:
      SetColor(0xCC,0x66,0x66);
    break;
    case 8:
      SetColor(0x12,0xA2,0x7E);
    break;
    case 9:
      SetColor(0xF0,0x80,0x32);
    break;    
    case 10:
      SetColor(0x30,0xFF,0xFF);
    break;    
  }
}
//=========================================================================
//                   Write Color Value
//=========================================================================
void SetColor(char R,char G,char B)
{
  analogWrite(REDledPin,R);
  analogWrite(GREENledPin,G);
  analogWrite(BLUEledPin,B);  
}

Results

Press switch and see that we have around ten different colors; You can change the color using SetColor(R,G,B). try different values of RGB.

Moving message display using arduino

Matrix Display Interface with MAX7219

The MAX7219 LED driver saves microcontroller pins and processing time. It uses only three IO pins of an Arduino.  It is easy to connect multiple displays by connecting DIN and DOUT pins.

Using a single MAX7219 you can drive 64 LEDs while you only need 4 wires to interface it to a microcontroller. In addition you can daisy chain multiple MAX7219 chips for bigger displays. Continue reading Moving message display using arduino