Control Led from phone to arduino

Hello, I've been making an app on MIT App Inventor that basically involves controlling several leds' brightnesses simply by sliding your finger from one side to the other (that's a graphic feature coming from the app) and each thumb position will send a value to arduino that will regulate the led's brightness (by using the pwm pin) and so far so good, it worked. But now that I have to put more leds, I also have to make sure arduino knows which led I want to control, so I've thought about creating a new variable in my program that, when sent together with the led value, it would recognize which led I want to use. The only problem is that I can't divide the 2 values read on the serial monitor. Here, I will send the arduino code below! (I can't send the file so I'll have to paste it, don't mind the first part in the loop since that's another part of the program)

#include <dht_nonblocking.h>
#define LED_BLUE 9

static const int DHT_SENSOR_PIN = 2;
DHT_nonblocking dht_sensor( DHT_SENSOR_PIN, DHT_SENSOR_TYPE );
unsigned long lgUpdateTime;
int led_value;
int led_color;
String led_color_str;
String led_value_str;
void setup()
lgUpdateTime = millis();
pinMode(4, INPUT);
static bool measure_environment( float *temperature, float *humidity )
static unsigned long measurement_timestamp = millis( );

if( millis( ) - measurement_timestamp > 1000ul )
if( dht_sensor.measure( temperature, humidity ) == true )
measurement_timestamp = millis( );
return( true );

return( false );

void loop()
{ float temperature;
float humidity;

if (digitalRead(4) == HIGH) 
   {if( measure_environment( &temperature, &humidity ) == true )


Serial.print( temperature );
Serial.print( humidity );



 if (Serial.available() > 0) {

  led_color_str = Serial.readStringUntil(';');
  int led_color = led_color_str.toInt();

   case 1: 
           int led_value =;
           led_value = map(led_value,0,100,0,255);

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.