Serial connection of Processing and Arduino

Hello @jinalilili,

A '1' (character) and 1 (integer number) are two different things.

Processing:
myPort.write(1);

Arduino:
if (val == '1') // This will NEVER be equal to 1

Reference:
https://processing.org/reference/char.html

This is a common error for those new to programming and serial communications.

Keep at it!

char a = '1';

// This will NOT be equal:
int b = 1;

//These will be equal:

//int b = 49; // ASCII for '1' in decimal
//int b = 0x31; // ASCII for '1' in hexadecimal

if (a == b)
  println("Equal");
else
  println("NOT Equal");

:)