Author Options:

Code for controlling the brightness of LED using Bluetooth module HC-05-v1.0? Answered

I am using arduino ATmega328 micro-controller.
i tried some analog coding to control the brightness via Bluetooth module but the output value of the LED is constant.

The code I used is,

int ledPin = 5; 
int fadeValue = 0;
void setup()

void loop() {
  // fade in from min to max in increments of 5 points:
    if (Serial.available() > 0)
           fadeValue = (int) Serial.read();
           for(int i=0;i<=fadeValue;i+=5)
               analogWrite(ledPin, i);


I may be wrong, but I think talking to the HC05 needs more than a single
read from it. IIRC, you need AT commands to do it, and you may even
need handshaking signaks, like CTS and RTS. The BT module will say "I have data", by asserting the RTS line you then read it by asserting your CTS line.