Arduino To Processing Error For Capactive Sensor

  1. You are sending a long data type as a String with Serial.print()
  2. You are receiving a String and converting it to an int in your code.
  3. Consider saving String in array initially until you get this working and then convert the String to a long data type when it is required.

Breaking into steps is easier to debug code.

Keep in mind that print() a String or a number (int, long, etc.) will show the same on the console but they are two different data types! You must keep track of them and use as per your requirements (data or string).

It is your code so you must decide how you want to do this.

:slight_smile:

Examples of conversions:

void setup() 
  {
  int num = 12345678;
  println(num);
  
  String s1 = "12345678";
  println(s1);
  
  int num2 = int(s1);
  println(num2);
  
  num2 = parseInt(s1); //Same as above
  println(num2);
  
  String s2 = "1234567890";
  println(s2);
  
  long num3 = 1234567890;
  println(num3); 
  
  long num4 = Long.parseLong(s2);
  println(num4); 
  }
1 Like