I bought a Qtr-8RC a few days ago. I want to detect black and white lines. However I cannot get any response from the sensors. I went through all of the descriptions and instructions on your website. But I cannot make it works. My micro-controller is MSP432. I’m using Energia IDE which is completely the same with Arduino IDE. But I coudn’t get any response when I used your library’s examples. The result is always around 0. No matter how far the sensor is from the line and white paper.
I suspected that Energia has some differences with Arduino, So I went through your library cpp code and test all of the commands and functions, like Micros(), pinMode(), etc. separately on my Micro-controller. They work properly and there is no problem with the compatibility of Energia and Arduino.
However, I thought that maybe there is something incompatible with your library that I cannot recognize. So, I wrote my own code also. My code is really simple. Here is my code for testing one of the sensors which was connected to pin 3.
int timee;
int sensor_values;
void setup() {
Serial.begin(9600);
}
void loop() {
pinMode(3, OUTPUT);
digitalWrite(3, HIGH);
delayMicroseconds(20);
pinMode(3, INPUT);
digitalWrite(3, LOW);
timee = micros();
unsigned long startTime = micros();
while (micros() - startTime < 2500)
{
timee = micros() - startTime;
if (digitalRead(3) == LOW)
sensor_values = timee;
}
Serial.println(timee);
delay(500);
}
However, again the response was always around zero and there wasn’t any change when I hold black and white paper in front of it. I know that the optimal distance is 0.3mm.
Then I thought maybe I can use pulseIn() function. I wrote the following code.
void setup() {
Serial.begin(9600);
}
void loop() {
pinMode(3, OUTPUT);
digitalWrite(3, HIGH);
delayMicroseconds(20);
pinMode(3,INPUT);
digitalWrite(3, LOW);
Serial.println(pulseIn(3, HIGH));
}
Again no response. I wrote another code to check whether the sensor works. I used a LED and connect it to the 4th pin. and I wrote the following code.
void setup() {
pinMode(4, OUTPUT);
}
void loop() {
pinMode(3, OUTPUT);
digitalWrite(3, HIGH);
delayMicroseconds(20);
pinMode(3, INPUT);
digitalWrite(3, LOW);
if(digitalRead(3)){
digitalWrite(4, HIGH);
}
delay(500);
digitalWrite(4, LOW);
}
It simply check whether the sensor works. But the led didtn’t turn on at all.
In none of the aforementioned situations, your library and my own codes, I haven’t received any response from the sensors. In all situation LED ON pin was disconnected and I checked the LEDs with my camera and they were on.
Then I thought maybe the sensors are QTRA, though according to your instruction they are QTR-8RA. So, I checked the sensors with ADC. moreover I used your library and examples for QTR-8A but no response again.
I don’t know what should I do to make the sensors working. I’m struggling with them for a couple of days but no progress at all.
The wire connections are really simple. VCC to 5V, GND to GND and sensor1 to pin 3. nothing special. Also I’m pretty sure about my soldering. everything is in good condition.
I bought another sensor and it didn’t work also. I really appreciate your help.
regards,
Mehdi