I have an IR sensor module() and i have attatched it to my arduino connecting the GRD and VCC pin of the sensor to the arduinos 5V and GND. I then connected the output pin of the sensor to the digital pin 8 of the arduino.
The usual logic of the sensors is that when you place it in front of a white surface the output goes HIGH (1) and the indicator light comes on. but in my case it does the opposite. I ran an experiment to test my hypothesis. I tried this code with my left sensor to see what output i would get in the serial monitor.
//Start of Code
int ls, rs;
void setup() {
pinMode(8, INPUT);
Serial.begin(9600);
Serial.println("Sensor is ready");
}
void loop() {
int ls = digitalRead(8);
Serial.println(ls)
delay(1000); // If you dont but delay serial monitor will print multiple values of POT
}
//End of Code
When i placed the sensor in front of a white surface the serial monitor was displaying a LOW(0) output instead of high even though the indicator LED light was on, proving that there is something wrong with the logic of the sensors. Is there any way i can change the output i get with my sensors?
What makes you sure of the default output state of such modules?
You can invert the signal in code.
I wonder what's the purpose of that IR receiver. Remote control uses a carrier frequency of about 40kHz, a white surface should not result in any output, and it does not have an indicator LED. Do you have an IR light barrier module? Or a motion sensor? Any link to the data sheet were helpful.
To make life easier for those who are willing to help you, please give information about your project, the components used, if possible images and links.
This IR sensor of yours, what model is it? Do you have an image, is there a link that we can see or see its characteristics.......?
Thank you @anon57585045. Its my first time submitting to this forum. I will henceforth put the code in the code tags and remove black lines. Ive tried the code and its giving the output i wanted.
Hi @DrDiettrich, thans for the advice. I'll invert the signal in code instead. The project i am working on is a line follower robot. sorry im new to the forum and didnt read the instruction before posting.