Hello, I am new to this forum and arduino programming. I have a question regarding the arduino code that relates to my project.
The thing is, I am trying to use an android app to remote control the led brightness through bluetooth, however, I just couldn't to get my code right no matter how hard I work on it. Can someone please help me on this ?
[Note: I am using the slider feature on the app, the min value of the slider is set to 0 and the max is 255]
char value = 0; //Variable for storing received data
Serial.begin(9600); //Data bits rate per second for HC-05 bluetooth device
pinMode(dimled, OUTPUT); //Make pin 9 as individual output power
if(Serial.available() > 0) // Send data after receive signal:
value = Serial.read(); //Read the incoming data
Serial.println(value) ; //Print Value inside data in Serial monitor
analogWrite(dimled, value); //LED brightness control
So, basically my current code is able to trigger the led from off, but no matter how I drag the slider to send the input, the light's brightness won't change , and it won't turn off when I drag the value to 0.