Serial OTG. Arduino CH340. FTDI. rkl099's Extension

7.- Testing version 2022-10-19.

p10A_OTG_Add.aia (190.4 KB)

https://github.com/rkl099/Appinventor_Debug

  • Arduino UNO (CH340). Cable OTG. Cable USB.

otg17b

  • Settings / Additional settings / OTG / Enable OTG.
    otg26

  • Android 9. MIT Companion and installed.

  • Arduino UNO (CH340)
String a;
String b;
int c;
int d;

void setup() { 
  Serial.begin(9600);
}

void loop() { 
  if(Serial.available()) {
    a = Serial.readStringUntil(',');
    b = Serial.readStringUntil('\n');
    c = a.toInt() + b.toInt();
    d = a.toInt() * b.toInt();
    Serial.print(c);
    Serial.print(",");
    Serial.println(d);
}
}
  • App sends two numbers separated by commas.
  • Arduino receives them via Serial.
  • Separate the two numbers.
  • Add them and multiply them.
  • Returns the addition and multiplication separated by commas.
  • App receives the data, converts it into a list and displays it.

otg_5

otg_6

1 Like