Can't get Arduion.cc DigitaReadSerial Example to work. PLEASE HELP

I'm using a regular UNO Rev.3 board, with the sketch downloaded from "Examples> Basic> DigitalReadSerial". Nothing comes up on the Serial Monitor window. Yes, baud is 9600. Yes, com is correct. Yes, board is wired correctly (same as for the "Button" example, which works fine.) Please help. Thanks a million!

Please do not cross-post. Other topic deleted. Replies go here.

So you are saying you have a blank serial monitor screen? Take a picture of your wiring and show us. Copy your sketch from the IDE and show it to us.

So to clarify, the serial monitor baud rate (located in bottom right corner of terminal) matches the baud rate set it your code, 9600?

Thanks so much for your help. Baud rate: Yes, both are 9600. Sketch: Please refer to the sketch is on the Arduino.cc website under Examples> Basic> DigitalReadSerial. Wiring: The bread board wiring for this example is exactly the same as the bread board wiring for the Button sketch, also on the Arduion.cc website, under Examples> Digital. Thanks again.

We ask for things because posters sometimes think everything is OK but a second set of eyes sees something they miss. When you upload your sketch does it do it ok?

Thanks again so very much for your ideas on this problem.
Here is an attempt to show all details.

The SKETCH is downloaded from the Arduion website, File> Examples> Basic> DigitaReadSerial.
You will see it below.

The WIRING is from Arduino for Dummies by John Nussey.
I’ve attached a scan of the page.
I know my wiring is correct, because The “Button” example on the Arduino website uses the exact same wiring, and it works fine.

SERIAL MONITOR WINDOW, I also attached a screen save of the serial monitor window.

Thanks again for your help.

/*
  DigitalReadSerial
 Reads a digital input on pin 2, prints the result to the serial monitor

 This example code is in the public domain.
 */

// digital pin 2 has a pushbutton attached to it. Give it a name:
int pushButton = 2;

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
  // make the pushbutton's pin an input:
  pinMode(pushButton, INPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input pin:
  int buttonState = digitalRead(pushButton);
  // print out the state of the button:
  Serial.println(buttonState);
  delay(1);        // delay in between reads for stability
}

Try: pinMode(pushButton, INPUT_PULLUP);

And for debug: delay(100);

LarryD:
Try:
pinMode(pushButton, INPUT_PULLUP);

Surely not with an external pull down?

Add the line below so you can see if the comms is working at all

void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
  Serial.println("Starting serial comms....."); //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

And as suggested, post a pic of your actual circuit, not just the one from the book.

Surely not with an external pull down?

You are right, the image is so big for my iPad I did not scroll up far enough to see the switch went to 5V.

Will the OP please confirm the input pin goes High and Low using a DVM? Also do Serial prints work in other sketches?

Thanks again so very much for your help.
I don’t know what you mean by “Surely not with an external pull down?”
Is my wiring wrong?

I added INPUT_PULLUP, but it didn’t seem to make any difference.

There appears to be sporadic communication.
For example, if I toggle the serial monitor on and off, I occasionally get a string of zeros and occasionally a one.
When I added the line which you suggested to test communication, I would occasionally get a partial reply such as “Startin” or “Sta”.

You asked if I have serial communication problems with other Arduino examples.
Yes, I do.
Just today I wired and downloaded File> Examples> Analog> AnalogInOutSerial.
Once again the results were sporadic as I toggled the window off and on.
Usually it would display nothing, but occasionally I would get several lines of the anticipated input and output values.

It’s almost like my computer is trying to communicate at a different baud rate.
The serial monitor window is set for 9600.
I tried the sketch on another computer with the same results.

Two photos of my wiring are attached.
The blue wire goes to digital input 2.
The orange to 5 volts.
The green to ground.
The resistor is 10K.
Once again, the same wiring works great with the Button example.
What do you think?
Thanks a million!

Question: In Arduino's example sketches, DigitalReadSerial and AnalogInOutSerial, isn't UNO writing to the serial monitor window hundreds of times a second? Why shouldn't we see a continual blur of values streaming across the screen? Thanks.

Will you please confirm the input pin goes High and Low using a volt meter?

Once again the results were sporadic as I toggled the window off and on.

Maybe suggest an intermittent on the Arduino.
Look for poor solder joints.
Is this a counterfeit Arduino?

EDIT:
The first image is not wired properly.
I see now the lead on the resistor is bent around so it is OK.

Try this sketch and report back whether LED 13 follows the push on the switch:

/*
  DigitalReadSerial
 Reads a digital input on pin 2, prints the result to the serial monitor

 This example code is in the public domain.
 */

// digital pin 2 has a pushbutton attached to it. Give it a name:
int pushButton = 2;

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
  // make the pushbutton's pin an input:
  pinMode(pushButton, INPUT);
  pinMode(13,OUTPUT);  // <<<<<<<<<<<< Add this line, and
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input pin:
  int buttonState = digitalRead(pushButton);
  digitalWrite(13,buttonState);  // <<<<<<<<<<< Add this line too
  // print out the state of the button:
  Serial.println(buttonState);
  delay(100);        // delay in between reads for stability
}

2-8-2014 8-38-00 PM.jpg

I don’t know what you mean by “Surely not with an external pull down?”
Is my wiring wrong?

I added INPUT_PULLUP, but it didn’t seem to make any difference.

Sorry, that one was for LarryD.

Pullups and Pulldowns are mutually exclusive and Larry hadn’t realised there was a pulldown.

EDIT… one other thing to check, is that you have the switch oriented correctly on the board. I can’t see the legs in the photo, but those square, 4leg switches are often 90 degrees out. Look at the pic I attached of a typical switch and see if you have the switching correct. Might be an idea to get your ohm-meter out and satisfy yourself which pins are always connected and which are switched.

pushbutton.jpg

Wow! What a problem!
Thanks for the suggestions, and the sketch with the LED 13 test function.
Yes, LED 13 does go on when the button is pushed.
I’ve tried the sketch with one clone, and two genuine UNO Rev.3 boards from Italy.
I also tried it on two computers.
Always the same very sparse and sporadic communication with both the DigitalReadSerial example, and the AnalogInOutSerial example.
Although the AnalogInOutSerial example does communicate a little more frequently.
Any more ideas?
Have you tried it?
Does it work O.K. for you?
Thanks again.

Works fine. Have you tried a different USB cable?

Yes, I tried a different USB cable.
Thanks for the suggestion.

I tried a third sketch which uses serial communication.
It doesn’t communicate either.
There must be some problem with my computers.
Neither communicate with Arduino, but they do fine with cameras, scanners, blue tooth, etc.
Any ideas other ideas or things to test???
Surely someone else must have had this problem.
Thanks.

PROBLEM SOLVED I deleted Arduino software and reinstalled it. No more problems.