Can't receive INPUT! Is my Duemilanove broken?

Hello
Something strange has happend to my Duemilanove.
It seems like it can’t receive INPUT. Whenever I have some external component sending a signal to the board on any pin, I get no response from the Duemilanove. I’ve tried using the println so that I can see values in the serial monitor, but no luck. For digital I just get “0” and analog values fluctuates, just like if nothing is connected.

I have no problem using OUTPUTs, like driving a small motor or relay. That works fine.
It only happens when I try to get INPUTs.

When I first started using the board, everything worked fine. It started acting up about a week ago.

Is there some sort of “RESET” function or something else that I’ve missed, or is the board just broken?

hmm,

#define PIN 2
#define LED 13

void setup(){
  Serial.begin(9600);
  pinMode(PIN, INPUT);
  pinMode(LED, OUTPUT);
}

void loop(){
  if(digitalRead(PIN){
    Serial.println("Pin High");
    digitalWrite(LED, HIGH);
  }
  else{
    digitalWrite(LED, LOW);
  }
}

Should squirt some text out the serial port if the pin is high, and light up the pin 13 LED :)

is there some sort of "RESET" function

No.

How are you wiring things up? Best if you have a switch connected from the input pin to ground. Then take the code above but enable the pull up resistor by making the setup like this:-

void setup(){
  Serial.begin(9600);
  pinMode(PIN, INPUT);
  digitalWrite(PIN, HIGH);  // enables internal pull up
  pinMode(LED, OUTPUT);
}

I've tried using the coding exemples you posted, but I don't get anywhere. I'm using a active RFID reader (a simple luggage alarm), and it gives out pulses wired to digital pin 7 when the tag is present. The strange part is that the Arduino reports the incoming pulse as HIGH, even if the wire is NOT connected. If I'm not mistaken, zero power should be LOW, so why does this happen. Is my arduino broken in some way? I worked fine when I first got it.

int PIN = 7; int LED = 13; int val;

void setup() { Serial.begin(9600); pinMode(7, INPUT); digitalWrite(7, HIGH); pinMode(13, OUTPUT);

}

void loop() { val = digitalRead(7); if (val = HIGH) { Serial.println("Pin High"); digitalWrite(13, HIGH); }

else { Serial.println("Pin Low"); digitalWrite(13, LOW); } }

  if (val = HIGH)

You are assigning the value of HIGH to val with this statement. The result of an assignment statement is the value being assigned. Since that is not 0, the if test is true.

Try using the equality operator (==) rather than the assignment operator (=).

Nope, it doesn’t work. I get the same result. Thanks for the advice though.

int PIN = 7;
int LED = 13;
int val;

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

pinMode(7, INPUT);
pinMode(13, OUTPUT);
digitalWrite(7, HIGH);
}

void loop()
{
val = digitalRead(7);

if (val == HIGH)
{
Serial.println(“Pin High”);
digitalWrite(13, HIGH);
}

else
{
Serial.println(“Pin Low”);
digitalWrite(13, LOW);
}
}

I've tried using the coding exemples you posted, but I don't get anywhere. I'm using a active RFID reader (a simple luggage alarm), and it gives out pulses wired to digital pin 7 when the tag is present. The strange part is that the Arduino reports the incoming pulse as HIGH, even if the wire is NOT connected. If I'm not mistaken, zero power should be LOW, so why does this happen. Is my arduino broken in some way? I worked fine when I first got it.

With the pull-up enable its normal that it reads HIGH with nothing connected to the pin, remove this line and try again:

digitalWrite(7, HIGH);