• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

MIT APP INVENTOR

Q&A Forum › Category: ESP32 › MIT APP INVENTOR
0 Vote Up Vote Down
Juan David Barrero asked 4 years ago

I’m still working with MIT app inventor and i am trying to change the pwm using a slider but i do not kwon how to read tha value in my ESP32 i don’t kwon what function use or how to read it without become my ESP32 into a client because i want to send and receives data

9 Answers
0 Vote Up Vote Down
Rui Santos Staff answered 4 years ago

You should implemente a similar method as the ON/OFF buttons. Basically, when you move the slider you need to send those PWM/slider values to the ESP32 (like you would do with the buttons):

0 Vote Up Vote Down
Juan David Barrero answered 4 years ago

but how can i get the value from the slider in my code?, the problem is that the value is integer

0 Vote Up Vote Down
Juan David Barrero answered 4 years ago

// Setup callback when new value is received (from the Android application)
class MyCallbacks: public BLECharacteristicCallbacks {
void onWrite(BLECharacteristic *pCharacteristic) {
std::string rxValue = pCharacteristic->getValue();

if(rxValue.length() > 0) {
Serial.print(“Received value: “);
for(int i = 0; i < rxValue.length(); i++) {
Serial.print(rxValue[i]);
}

ledcWrite(ledChannel,atoi(rxValue) );

}
}
};

do not kwon what to do

0 Vote Up Vote Down
Rui Santos Staff answered 4 years ago

What does it print in your serial monitor?

0 Vote Up Vote Down
Juan David Barrero answered 4 years ago

Error rxValue must be unit_32, so i have the problem in the mit app i can’t save the slider value as string or i do not kwon how do that, (that will solve my porblem) or how can i get in my arduino’s code a function that recives integer number o unit_32

0 Vote Up Vote Down
Rui Santos Staff answered 4 years ago

But which code line is giving you that error? Unfortunately I’m not understanding your exact problem. This is a variable conversion error. What’s the rxValue variable type and which type do you need?

0 Vote Up Vote Down
Juan David Barrero answered 4 years ago

class MyCallbacks: public BLECharacteristicCallbacks {
void onWrite(BLECharacteristic *pCharacteristic) {
std::string rxValue = pCharacteristic->getValue();
if(rxValue.length() > 0) {
Serial.print(“Received value: “);
for(int i = 0; i < rxValue.length(); i++) {
Serial.print(rxValue[i]);
}
here is the problem pwm use led channel and an integer for duty cycle but rxvalue is a String and MIT APP inventor doesn't send the slider value as a string so i must send it as a byte or as integer and that is the problem i'll never will eable to get that value because rxvalue just receives Strings

0 Vote Up Vote Down
Juan David Barrero answered 4 years ago

MIT

0 Vote Up Vote Down
Rui Santos Staff answered 4 years ago

You can convert a String to an integer using the .toInt() method. You can find more information about that function here: https://www.arduino.cc/reference/en/language/variables/data-types/string/functions/toint/

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] SMART HOME with RPi, ESP32, and ESP8266 (version 1.2) March 8, 2023
  • [eBook Updated] ESP32-CAM Projects (version 1.3) January 7, 2023

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2023 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.