Please explain Serial.print to a dumb newbie

Hi everyone

I'm a complete newcomer to the strange, exciting world of Arduino!

I've spent the last few days going through the examples and the programming reference, so I thought I was ready for my first sketch. But then I realized that i just don't understand a really simple thing...

How does the "Serial.print" command work? In other words, where does it print to? A file? The screen? I'm confused...!

I'm running a Duemilanove and Windows XP(SP3)

Thanks,
Ned

It simply sends whatever you print out the serial port on your arduino.

So to "see" it you would have to have something that listens to the serial port.

You could use the serial monitor in your Arduino IDE, a terminal emulation program like the Windows "Terminal" app. or a custom PC program or .....

So "Print" is somewhat of a misnomer, i personally think that serial.send would be a better name for the function.

a...HA! Thanks. (...and thanks for not laughing at me :-[ )

I'll use the IDE serial monitor for now... not sure how to set up Terminal to listen to the serial port. I guess I'll figure it out...

Ned

Why should any one laugh at you? We all had a similar question when we began with programming :wink:

The C language has a lot of print like functions, and most of the time you can specify where to print to. file, screen, device, memory, etc. Serial.print is just a shortcut for some complex function to tell that you should 'print' something to the serial port.

I should like to add:
Serial.print uses I/O #1 of the Arduino pins; you might have noticed that it is labeled TX (rather tah print...). This line is also (unnoticeably for the beginner) connected to the USB port. So don't do anything with pins 0 and 1 if you use serial communication.

Yeah, heed deSilva's warning... nobody told me that and I used digital 0 and 1 as an output and input for a sensor and spent WEEKS trying to figure out why Serial.print stopped working! Talk about almost making a noob break down in frustration. To make things worse, it was the very first project I ever made on my own after doing a bunch of example projects. Man I thought I was in the wrong hobby.

So how do I get around that? It's a bit of an issue, as I will ultimately need all the analog inputs for my project

Ned

as I will ultimately need all the analog inputs for my project

No digital pins 0 & 1 not analogue pins 0 & 1

Ooops... dumb reply! Sorry

N

May be this is a little bit advanced, but needs mentioning from time to time.
TheArduino/AVR has exactly ONE AD-Converter. That it uses 6 pins (or 8 with the SMD versions) is a kind of fake, called multiplexing. You can easily extend the number of analog inputs through a 50 cents chip called 74HC4051 to as many lines as you like if you are not too demanding in your sampling frequency...

Now that's very interesting. Ultimately I will need about 12 analog inputs (mostly thermistors) Pinpoint accuracy is not required and sampling frequency will probably not be an issue - max once per hour. How do I do this using a 74HC4051?

(BTW, I'm an accountant, not an electronics engineer)

Ned

You can easily extend the number of analog inputs through a 50 cents chip called 74HC4051 to as many lines as you like if you are not too demanding in your sampling frequency...

Can you use that same chip for a 12-bit ADC like the MCP3208?

I think so... But each of such multiplexers adds noise to the analog signal by their external wiring and internal working. This might already influence the LSB of a 12-bit ADC. It will hardly influence a 10 bit ADC @5V (=5mV)

Ultimately I will need about 12 analog inputs

have a look at this project there are 16 analogue inputs on this:-
http://www.thebox.myzen.co.uk/Hardware/MIDI_Footsteps.html

Now that's very interesting. Ultimately I will need about 12 analog inputs (mostly thermistors) Pinpoint accuracy is not required and sampling frequency will probably not be an issue - max once per hour. How do I do this using a 74HC4051?