#include SoftwareSerial ble(2, 3); int value = 0; //Integer to control motor speed const int CW_pin = 4; String command = ""; //String to hold commands from Android App long display_updated_time; //timestamp of last screen update void setup() { Serial.begin(9600); ble.begin(9600); pinMode(CW_pin, OUTPUT); } void loop() { command = ""; if (Serial.available() > 0) { //check for string commands from AppInventor command = Serial.readString(); //store command as a string } if (command.charAt(0) == 'C') { //If command starts with the letter "c" command.remove(0,1); //remove the first letter "c" from the string "c125" becomes "125" value = command.toInt(); //convert the rest of string into an integer } value=map(value,0,100,0,255); analogWrite(CW_pin,value); } }