ESP32 Bluetooth Slider LED App

Lelouch
Posts: 6
Joined: Wed Feb 14, 2018 4:14 am

ESP32 Bluetooth Slider LED App

Postby Lelouch » Sun Mar 04, 2018 1:37 am

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 ? :)

maneco
Posts: 9
Joined: Tue May 23, 2017 12:09 pm

Re: ESP32 Bluetooth Slider LED App

Postby maneco » Sun Mar 04, 2018 2:33 am

you could use dac output, somthing like:

Code: Select all

dacWrite(25,light);
instead of analog write

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: ESP32 Bluetooth Slider LED App

Postby WiFive » Sun Mar 04, 2018 11:06 pm

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

Lelouch
Posts: 6
Joined: Wed Feb 14, 2018 4:14 am

Re: ESP32 Bluetooth Slider LED App

Postby Lelouch » Sun Mar 04, 2018 11:32 pm

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

Who is online

Users browsing this forum: Google [Bot] and 109 guests