I wanted to exchange data via serial between teensy and android phone with an OTG cable (no bluetooth involved) and I succeeded following your advice! Thanks @defragster
https://play.google.com/store/apps/d...n.freeusbtools
Here is the simple code I wrote on the Teensy LC
IDE setup to USB type: "Serial"
Code:
// works perfectly with Tensy LC
// and USB Serial Terminal Lite https://play.google.com/store/apps/details?id=com.oneman.freeusbtools
// plus an OTG cable between Teensy and Android phone
const int LEDpin = 13; // Teensy LED pin = 13
const int buttonPin = 4;
boolean statusButton = false;
void setup() {
pinMode (buttonPin, INPUT_PULLUP); // in order to "press" the button: connect to ground
pinMode (LEDpin, OUTPUT);
Serial.begin(9600); // USB OTG serial com
}
void loop() {
unsigned char inByte = 0;
// listen to button and send to Android via OTG
if ((digitalRead(buttonPin) == HIGH) && (statusButton == false)) {
statusButton = true;
Serial.write("PRESSED");
}
if ((digitalRead(buttonPin) == LOW) && (statusButton == true)) {
statusButton = false;
Serial.write("RELEASED");
}
// écoute OTG pour recevoir les paramètres
if (Serial.available() > 0) {
// read the incoming byte from OTG
inByte = Serial.read();
// visual check of incoming data from phone: light the in-built LED
digitalWrite(LEDpin, HIGH);
delay(100);
digitalWrite(LEDpin, LOW);
}
}