Serial communication

int a; int b; int c; void setup() { Serial.begin (9600); Serial.println("Unesi prvi broj"); } void loop() { while (Serial.available ()>0){ a = -48; Serial.println (a); delay (1500); Serial.println ("Unesi drugi broj"); b = (); Serial.println (b); delay (1500); c =a+b; Serial.println (c);

I need help. When I put first num I can't put another it just prints - 49 in ascii code. Please help.

This cannot be your real code. There are at least two missing }'s, and their location may be significant. To post:

  1. Autoformat your code in the Arduino IDE by using CTRL-T.
  2. Copy your code and paste it using code tags (the </> button) so the code will
look like this!

If your code compiled (which it doesn’t), it appears that it attempts to check that at least one character is available, then reads two. What is up with that?


If you want a letter to print, use a char variable.