Page 1 of 1

ESP32 Bluetooth Slider LED App

Posted: Sun Mar 04, 2018 1:37 am
by Lelouch
Hey

I have an app which can read sensor values from the esp32 over BLE and i can also write to the seriell monitor. Now i wanted to make an Slider to controll the brightness of a LED. I found an nice example but it didnt work for me because he uses a arduino101 and has the analogWrite command which dont work on esp. (btw: im using ESP32_BLE_UART example)

Code: Select all

if (switchCharacteristic.written()) {

          Serial.println(switchCharacteristic.value());

          int light = map(switchCharacteristic.value(),10,49,0,255);

          analogWrite(lightPin,light);
has some one a idea ? :)

Re: ESP32 Bluetooth Slider LED App

Posted: Sun Mar 04, 2018 2:33 am
by maneco
you could use dac output, somthing like:

Code: Select all

dacWrite(25,light);
instead of analog write

Re: ESP32 Bluetooth Slider LED App

Posted: Sun Mar 04, 2018 11:06 pm
by WiFive
maneco wrote:you could use dac output, somthing like:

Code: Select all

dacWrite(25,light);
instead of analog write
No, because analogwrite in this context is PWM

Re: ESP32 Bluetooth Slider LED App

Posted: Sun Mar 04, 2018 11:32 pm
by Lelouch
Hey now with this code:

Code: Select all

  
  
      std::string rxValue = pCharacteristic->getValue();
  
     if (rxValue.length() > 0) {  
         int light = map(rxValue.length(),10,49,0,255); 
          Serial.println(rxValue.length());
         dacWrite(LED,light);
i only get 4 4 4 .... what do i have to write instead of length ?

btw: I think I recieve strings .. so will this work ?.. sry im pretty noob in programming