Wednesday 18 September 2019

How to run Fast LED programs on addressable LEDs using Arduino

Fast LED is a library of programs for controlling addressable LEDs. Before using the libraries or working on writing your own code you need to know what LEDs you are using and how many of them will there be. Make a note of what pin, or pins will you be putting the LEDs onto.

Download the latest release of the Arduino IDE for your operating system. You may already have this.

Open Arduino.

In the 'Tools' menu navigate to 'Manage Libraries'. In the 'Filter your search' box type 'Fast LED'. You should get something like this:



Click on 'install', wait until it installs then from 'File' 'Examples' scroll down and 'Fast LED' should be down towards the bottom of the list. You can then select one of the Fast LED libraries for example 'ColorPalette'. Select this and the code opens in Arduino.

Among the first few lines are the ones to alter depending on your requirements:

#define LED_PIN     5
#define NUM_LEDS    50
#define BRIGHTNESS  64

#define LED_TYPE    WS2811

Change these to match the string of LEDs you are using. 

In my video example below, I'm using Pin 5, 22 LEDs, 100 brightness and a string of WS2811 addressable LEDs.




Wednesday 4 September 2019

How to control LED via Bluetooth and Arduino

I will cover how to set up Arduino, upload the code, test in serial mode, then test using Android app.

Things required:

1. Arduino Uno board
2. Jumper wires
3. HC-05
4. LED


1. Make the following connections:

Arduino                              HC-05
TX              ====>             TX
RX              ====>             RX
5V              ====>             VCC
GND           ====>             GND

LED short wire ====>       GND of Arduino
LED long wire ====>         pin 8 of Arduino

2. Temporarily remove the TX and RX from the HC-05.



3. Upload the following code:

------------------------------------------------------------------------------------------------------------------------------------
void setup() {
Serial.begin(9600);
 pinMode(8, OUTPUT); // put your setup code here, to run once:
 }

void loop() {
  // put your main code here, to run repeatedly:
 if(Serial.available()>0)
   {     
      char data= Serial.read(); // reading the data received from the bluetooth module
      switch(data)
      {
        case 'a': digitalWrite(8, HIGH);break; // when a is pressed on the app on your smart phone
        case 'b': digitalWrite(8, LOW);break; // when b is pressed on the app on your smart phone
        default : break;
      }
      Serial.println(data);
   }
   delay(50);

}
------------------------------------------------------------------------------------------------------------------------------------
4. Replace the TX and RX cables as above.

5. Open serial monitor in Arduino program.

6. Change Baud rate to 9600 and select 'no line ending'.

7. Enter a to turn LED on, enter b to turn LED off.


Using via Bluetooth app. I use Bluetooth Terminal

8. Swap the TX and RX cables around on the Arduino.

9. Pair up using Bluetooth app.

10. Enter a in app to turn LED on, enter b in app to turn LED off.

There is a video showing this in action here:


How to enter AT mode in HC-05 Bluetooth module

I will cover how to change password, name or mode (master or slave) in HC-05 Bluetooth module. 


Things required:

1. Arduino Uno board
2. Jumper wires
3. HC-05


1. Upload a blank program to your Arduino.

2. Make the following connections:

Arduino                              HC-05
TX              ====>             TX
RX              ====>             RX
VCC            ====>             VCC
GND           ====>              GND
HC-05 bluetooth module
HC-05


3. Before powering up the Arduino, the little button on the HC-05 should be pressed and then released a few seconds after powering up the Arduino..  

4. The HC-05 in now in AT mode and its LED will blink approximately once every 2 seconds.

5. Open serial monitor in the Arduino program. The Baud rate should be selected to 38400 and both nl and cr should be selected.

6. Check some AT commands:

Type AT and press enter
The response should be OK

AT+ROLE? and press enter
The response is 0 or 1
0- Slave
1- Master

AT+UART? and press enter
The response is Baud rate

AT+PSWD? and press enter
The response is 1234    // that is the password.

For changing the password, command is AT+PSWD="1587"  
This command will set the password to 1587
Note: you need the quotation marks around the number selected.

There are other AT commands available at this link: