Adafruit: Arduino Tutorial

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
davidh
 
Posts: 155
Joined: Sat Feb 25, 2012 12:32 am

Adafruit: Arduino Tutorial

Post by davidh »

Hi,

I typed in the following program from the Adafruit Arduino Tutorial

/*
* Hello World!
*
*This is the Hello World! for Arduino
*It shows how to send data to the computer
*/

void setup()
{
Serial.begin(9600);

Serial.println("Hello World!");
}

void loop()
{

}

output: HHello World!

I'm not real sure why this happened. I know theres not a problem with the code. So maybe its some kinda electronic nonsense stuff :D ?

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Adafruit: Arduino Tutorial

Post by adafruit_support_mike »

It's probably a reset bounce. In essence, the microcontroller is tripping over its own feet.

When you establish a serial connection with the Arduino device, it automatically restarts the sketch currently in memory. Thing is, it also resets when you send a sketch to the device in the first place.

So.. what probably happened is that you loaded the sketch and it did two things: it sent the signal to initiate a connection with the Arduino programming environment on your computer, then immediately started pushing bits into the serial output buffer. When your computer responded to the connection, the sketch reset, went through an "okay, I've already asked for a connection" path in Serial.begin(), then went back to the beginning of your "Hello, world!" string to collect output bits.

Thing is, there was already an 'H' worth of bits in the serial buffer on the second pass, so your computer read that before letting the Arduino device start sending the string again.

User avatar
fmbfla
 
Posts: 110
Joined: Fri Jun 08, 2012 6:48 pm

Re: Adafruit: Arduino Tutorial

Post by fmbfla »

/*Put the
Serial.println("Hello World!");
In the void loop();
*/
void setup() {
Serial.begin(9600); // Start the Serial Conn and set your baud
}
void loop() { // every thing beyond this point " { " will repeat.

// this is the command in this case, "Serial.print " will continuously print the "text" to the (any) Serial Monitor) and will repeat forever in the loop.
Serial.print("Hello World!");

// Processors are fast so we need to slow them down. (1000) is one human second. (500) is Half a second and so on.
delay (1000); // Every second in your Serial Monitor you will see the text "Hello World".
//The same goes for going in the + range

}

User avatar
fmbfla
 
Posts: 110
Joined: Fri Jun 08, 2012 6:48 pm

Re: Adafruit: Arduino Tutorial

Post by fmbfla »

Your doing great just by asking Questions...... Keep up the good work you will be rewarded, Let your mind wander as you play, you will discover new ideas that ARE POSSIBLE ! :-)
If you don't know the answer to a problem, The stupidest thing you could do is not ask for help! :-)

davidh
 
Posts: 155
Joined: Sat Feb 25, 2012 12:32 am

Re: Adafruit: Arduino Tutorial

Post by davidh »

Thanks, its very encouraging to read your replies.
I did change the code

/*
* Hello World!
*
*This is the Hello World! for Arduino
*It shows how to send data to the computer
*/

void setup()
{
Serial.begin(9600);
}

void loop()
{
Serial.print("Hello World");
delay(1000);
}

This time there was no extra H as in the output. But I did say Hello World! alot of times :D

User avatar
fmbfla
 
Posts: 110
Joined: Fri Jun 08, 2012 6:48 pm

Re: Adafruit: Arduino Tutorial

Post by fmbfla »

Great, Now you can begin to really play with it. Just follow the examples @ arduino.cc and adaFruit. ( I am a new B as well, about a MONTH or so.)
When your ready Start on more fun stuff close your eyes and Imagine, Then Build/Buy Shields so you can connect devices that you can monitor or control or have the Arduino do the monitoring and Controlling for you :-) Happy Hacking! :-)

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”