Go Down

Topic: [Problem] IR Avoidance Sensor (KY-032 ?) cuts off  (Read 552 times) previous topic - next topic

a_slow_old_man

Hello Arduino Community,
I have a problem with my IR avoidance sensor module cutting off after getting a signal.

I hope the following video explains it better: VIDEO

I used this code from the website of the sensor producer:
Code: [Select]
//www.elegoo.com
//2016.06.13
int Led=13;//define LED port
int buttonpin=3; //define switch port
int  val;//define digital variable val

void  setup()
{
    pinMode(Led,OUTPUT);//define LED as a output port
    pinMode(buttonpin,INPUT);//define switch as a output port
}
void  loop()
{
  val=digitalRead(buttonpin);//read the value of the digita interface 3 assigned to val
  if(val==HIGH)//when the switch sensor have signal, LED blink
  {
      digitalWrite(Led,HIGH);
   }
   else
   {
       digitalWrite(Led,LOW);
    }
}


The pins are set correct on the Arduino Uno


and on the Sensor


The sensor does not react to slow movement in front of it, and even if it picks up an obstacle it only triggers for a very short time.

In Videos and Tutorials it behaves differently. It should give a continous signal while obscured.

I have tested it without lights already, but the problem stays the same even in a pitch black room.

Side note: I am using the "Avoidance" Sensor from the "Elegoo Upgraded 37 in 1 Sensor Modules Kit V2.0" set.


#####################################################################


I have searched on this forum and elsewhere for hints and came across this post

I removed the breaker and tried to get the pseudo code to work. I came up with this:
Code: [Select]
const int ledPin = LED_BUILTIN; //LED flash pin (builtin led)
const int enablePin = 9;//the number of the Enable pin (EN)
const int readPin = 3;//sensor read pin
/************************************************/
void setup()
{
  //pinMode(ledPin,OUTPUT);//define LED as a output port
  //pinMode(enablePin,INPUT);//initialize the digital pin as an output
  //pinMode(readPin,OUTPUT);//initialize the digital pin as an input
  digitalWrite(LED_BUILTIN,LOW);
}
/************************************************/
//the loop routine runs over and over again forever
void loop()
{
  digitalWrite(enablePin,HIGH);//turn the IR sensor module on
  delayMicroseconds(210);               //wait for 210 ┬Ás (8 pulses of 38kHz)
  if(digitalRead(readPin==HIGH))
  {
    digitalWrite(LED_BUILTIN,LOW);
  }
  else
  {
    delayMicroseconds(395);               // wait for another 15 pulses.
    if(digitalRead(readPin==HIGH))
    {
      digitalWrite(LED_BUILTIN,LOW);
    }
    else
    {
      digitalWrite(LED_BUILTIN,HIGH);
    }
  }

  digitalWrite(enablePin,LOW);//turn the IR sensor module off
}


Yet still it does not work. The Problem stays the same.


#####################################################################


Another idea was that maybe the IR diode is simply broken, but when I used an external IR diode the problem occured again:
VIDEO (please excuse my shaky hand)

What am I doing wrong?

I hope you can give me a hint in the right direction.

Thank you very much for reading my post until the end!




Annygnr

I'm having the same problem. Any advances in that?

Go Up