hello,
I'm working on project#13 from "Arduino Workshop". The sketch is to send a number to the arduino then the arduino will multiply it by 2 then return the answer the the serial monitor. The problem is when I send any number I also get another answer which is always the same value(sent -38/ multiplied by two -76).
here's the code:
// Project 13 - Multiplying a Number by Two
int number;
void setup()
{
Serial.begin(9600);
}
void loop()
{
number = 0; // zero the incoming number ready for a new read
Serial.flush(); // clear any "junk" out of the serial buffer before waiting
while (Serial.available() == 0)
{
// do nothing until something enters the serial buffer
}
while (Serial.available() > 0)
{
number = Serial.read() - '0';
// read the number in the serial buffer,
// remove the ASCII text offset for zero: '0'
}
// Show me the number!
Serial.print("You entered: ");
Serial.println(number);
Serial.print(number);
Serial.print(" multiplied by two is ");
number = number * 2;
Serial.println(number);
}
attached at the bottom is a pic of the results:
IDE updated to latest 1.05
using arduino duemilanove