mik3y / usb-serial-for-android

Android USB host serial driver library for CDC, FTDI, Arduino and other devices.
MIT License
4.83k stars 1.58k forks source link

i need to know how to run this sketch #364

Closed jafal633 closed 3 years ago

jafal633 commented 3 years ago

hi sir

if you kind explain to me how to run this sketch

`////////////////////////////////////////////////////////// // // supersimple application which sends 1 0 1 0 (toggle) // after each mouse click to the serial // // // basic infos // =========== // https://github.com/mik3y/usb-serial-for-android // Lib for android > 3.1 to use the USB interface in host mode (OTG) // https://github.com/inventit/processing-android-serial // Processing wrapper for the usb-serial-for-android lib // import com.yourinventit.processing.android.serial.*;

Serial SerialPort; boolean Toggle;

void setup()
{ println(Serial.list(this));

// this simple initialisation works only when one Serial consumer (e.g. an Arduino) // is connected. Serial.list provides a list with all Usb Serial devices attached // to this machine. SerialPort = new Serial(this, Serial.list(this)[0], 9600); }

void draw() {

}

void mousePressed() { Toggle = !Toggle; SerialPort.write( Toggle?"1":"0"); } `

and the Arduino code is

`//////////////////////////////////////////////////////////////////////// // // AndroidLedOn // // simpel serial in. If a 1 is received via serial, the led is // switched on. All other chars will switch of the leds. //

define NUMBER_OF_CHANNELS 8

define PINLED1 5

volatile char lastReceivedCharFromSerialIn = '\0';

void setup() {

pinMode(PINLED1, OUTPUT); Serial.begin(9600);

}

void loop() { digitalWrite( PINLED1, lastReceivedCharFromSerialIn == '1'); }

void serialEvent() { while (Serial.available()) { // get the new byte: lastReceivedCharFromSerialIn = (char)Serial.read(); } }

what i need to know how to add this tow files

1 AndroidManifest.xml ` 2 device_filter.xml

kai-morich commented 3 years ago

please ask processing-android-serial owner or at 'Processing for Android' comunity