digitalRead keeps returning HIGH



can tell me what's wrong setup?  basically, took concept post:
http://www.righto.com/2010/03/detecting-ir-beam-break-with-arduino-ir.html

below code, attached physical setup.

the led keeps blinking ... should because digitalread() returns high?  don't understand how can be?  originally, have 3-pins ir-receiver on board, took off , tried reset arduino , re-upload code.  green led still keep blinking!!  blinks if take out jumper pin 11 on uno!!


code: [select]


int recv_pin = 11;
int led_pin = 5;
 
void setup()
{
  serial.begin(9600);
  pinmode(led_pin, output);
  pinmode(recv_pin, input);
}

void loop() {

  digitalwrite(led_pin, low);
  int status = digitalread(recv_pin);
 
  if ( status == high )
  {
    digitalwrite(led_pin, high);
    delay(500);
    digitalwrite(led_pin, low);
  }

  delay(500);
 
}

without ir sensor in place, pin 11 floating. read low or high @ random. in case reading high. not mean anything.

with ir sensor in place, reads high when no ir signal detected. read low short periods when ir pulses detected. because sketch checks pin once every 500ms, miss these pulses. try changing sketch low.

paul


Arduino Forum > Using Arduino > LEDs and Multiplexing > digitalRead keeps returning HIGH


arduino

Comments