With the risk of stating the obvious, are the grounds of the IOIO and
Arduino connected?
I don't see any fundamental problem with the code, but maybe overlooking
something.

On Jul 30, 2016 05:16, "'Nick Jonas' via ioio-users" <
[email protected]> wrote:

> Hello!
>
> I'm trying to have an Arduino UNO send values to a IOIO board (
> https://github.com/ytai/ioio/wiki/UART) over UART.  As someone turns a
> rotary encoder, I want it to send a 0 for CW, 1 for CCW, and 2 for a
> press.  Everything checks out in the Serial Monitor from the Arduino, but I
> don't know how to read the values and parse them on the Java-end
> correctly.  It all comes through as seemingly random numbers, sometimes
> occasionally the correct number is there.
>
> I've tried both of these methods on the Arduino side, all of course work
> fine on Arduino's Serial Monitor:
>
> Serial.write(1);
>
>
> byte data[] = {1};
> Serial.write(data, 1);
>
>
> Serial.println("1");
>
>
> When doing Serial.write() with an integer or a byte array: on the Java
> side, I just get *mostly* 255, occasionally the correct number, and
> occasionally a random number in between 0 and 255:
>
> @Override
>   public void connect() throws ConnectionLostException {
>     try{
>       // rx pin = 6
>       mUart = ioio_.openUart(RX_PIN, IOIO.INVALID_PIN, 9600, Parity.NONE,
> StopBits.ONE);
>       mInput = mUart.getInputStream();
>
>
>     }
>     catch(ConnectionLostException e){
>       Log.e(TAG, "connection lost:" + e.getMessage());
>       ioio_.disconnect();
>       throw e;
>     }
>   }
>
>
>   @Override
>   public void loop(int loopCount) throws ConnectionLostException {
>
>
>     try{
>       byte[] response = new byte[1];
>       int read = mInput.read();
>
>
>     }catch(IOException e){
>       Log.d(TAG, "error: " + e.getMessage());
>     }
>   }
>
>
> I've also tried using BufferedReaders, while passing Strings through
> Serial.println, but a lot of crazy characters were getting output from the
> Java side (tried encoding in both UTF-8 and ASCII).
>
> Baud rates are matched up at 9600, and I'm on a 5v RX pin on the IOIO, and
> that pin is connected to the TX pin (pin 1) on the Arduino Uno.
>
> Does anyone point to a simple way of transmitting & receiving an integer?
>
> --
> You received this message because you are subscribed to the Google Groups
> "ioio-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/ioio-users.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"ioio-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/ioio-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to