Analog input problem

Hi,
I'm learning arduino with this tutorial:
http://www.ladyada.net/learn/arduino/lesson5.html

but my digital inputs dont show anything, when I look on serial monitor it reads only 1 and if I switch to ground it still shows 1

so what problem it can be? :-/

Post your code

You title the thread as analog input problem yet your trying to figure out a digital input.

So which one are you trying to do?

The code is on the tutorial page - it sounds like a hardware fault - perhaps the switch isn't pushed fully into the breadboard (those little pushbuttons don't sit very well in breadboards).

u can see code on the link, I checked hardware with continuity test everything works fine (did it about 4 times :slight_smile: ) How cab i check inputs with usual multimeter?
this is the code:

/*

  • Switch and LED test program
    */

int ledPin = 12; // LED is connected to pin 12
int switchPin = 2; // switch is connected to pin 2
int val; // variable for reading the pin status

void setup() {
pinMode(ledPin, OUTPUT); // Set the LED pin as output
pinMode(switchPin, INPUT); // Set the switch pin as input
}

void loop(){
val = digitalRead(switchPin); // read input value and store it in val
if (val == LOW) { // check if the button is pressed
digitalWrite(ledPin, HIGH); // turn LED on
}
if (val == HIGH) { // check if the button is not pressed
digitalWrite(ledPin, LOW); // turn LED off
}
}

U can see it on the link, I am using arduino serial made by myself with atmega8, OS Windows :slight_smile:

You can check the Digital pins on the Arduino by doing a digitalWrite(pin, HIGH) and then placing the MM on the pin and ground and see if it is outputting 5V. Then swap it to LOW and make sure your getting 0V.

so i must set pin2 on digital write?

sorry for my misunderstanding, ye i tried to conect it to analog input instead of digital, my bad :-[ ;D