Help - simple button!

Hi,

I have a Seeeduino and followed this tutorial for a simple button:

The problem is, when I read off digital pin 4, I simply get garbage, lots of squares and funny symbols. The code I use is:

Serial.println(digitalRead(4));

Help, Im really struggling to think what it could be, or why this is happening.

Thanks,
Lee.

Hi there

Are you using this code (from the DigitalReadSerial example):

void setup() {
  Serial.begin(9600);
  pinMode(4, INPUT);
}

void loop() {
  int sensorValue = digitalRead(4);
  Serial.println(sensorValue, DEC);
}

I guess you might wanna throw a

delay(1000);

in the loop.

-Fletcher

You left a number of things out of your post. All the code, for one thing. Where you are seeing the "garbage, lots of squares and funny symbols." for another.

If the "garbage, lots of squares and funny symbols." are appearing in the serial monitor, does the baud rate shown in the lower, right of the Serial Monitor match that of the Serial.begin() statement in the code?

In the button example, there is nothing attached to pin 4. Why are you reading that pin?

Hey thanks very much that was the problem!
Lee