I am wondering how did you come up with that solution at 18:15? It's really fascinating and saved me lots of time. I know it has been too much time since you release the video but if you remember what was the problem solving process you took I would be really appreciated. And even if you don't remember, can you tell me about what are your first steps to find the problem? (using debugger, reading code over and over etc.)
I am doing a line follower robot with qtr 8rc using the motor driver shield L293d model. I am not getting any calibration on screen, will u help me to fix it?
Sorry for the late reply, you can contact me through my site which will provide me with your email so I can contact you directly. Send me a message with your code and I'll definitely take a look. robotresearchlab.com/contact-me/
Hello sir! nice video! im just wondering if the qtrsensor library still works with a BFD-1000? I thought that it would still work since its just code but then you mentioned qtr sensor and its a qtr library... help me TT
Sorry about that, somehow the link was shortened improperly. I updated the link in the description but here's the link here as well robotresearchlab.com/2019/03/18/how-to-hookup-and-program-a-qtr-8-sensor-array/ Thanks for checking out my work.
I have 2 questions- 1. What position value does the readLine function give when all the sensors are over a white surface? 2. What if I wanted to get the position of a white line on a black surface? Is there any function in the qtr sensors library which can give position of the white line between 0 to (no. Of sensors -1)*1000 just like you did with the black line? Please help.I really learnt a lot from your videos
1. In theory, over an all white surface it would show the center as the result since each sensor would be weighted equally. However, this isn't really true since there is going to be some variance in the surface and in the calibration. Also, the library automatically accounts for when no sensor sees a line, it will return the first or last sensor (whichever last saw the line). So, to summarize, because of the way the library works, if you drive off the line going right, it will show 0, the left most sensor. If you drive off the line going left it will show the value of your right most sensor (7000 if you have 8 sensors). 2. This one's easy, the library can already handle this, there are two optional parameters for readLine(). In my code I just pass in the array which gets populated by the library with each sensor value. By default, the second parameter is QTR_EMITTERS_ON, and the third (which tells the library if it's white line) is set to false. All you have to do is provide these two optional parameters but change the last one to true so the library knows to look for a white line on dark background. It would look like this (not tested) unsigned int position = qtrrc.readLine(sensorValues, QTR_EMITTERS_ON, true); I hope that helps, thanks for watching and commenting.
Hello, I am using the QTR-8RC board and I followed this tutorial (including the soldering/wiring video) and I am not getting any values for the two sensors on the breakable part of the board. This is the second board where I've had this problem. Is there anything I need to do to enable the last two sensors?
Alright, so I figured it out not long after posting this. I am using this sensor with an Arduino nano. Normally, it is okay to use the analog pins for digital input (because digital input would just be either min analog or max analog input), and I made this choice because after hooking up the motor driver, I didn't have enough digital pins to use all digital pins for the sensor inputs. I fixed this by changing the last two sensor connections to my remaining two digital pins. The board works perfectly now.
@@Mekadrom Interesting, I've never seen this issue. All analog pins on Arduino boards should be able to be used as Digital. Maybe there is something with this particular library and Analog pins that doesn't mix well... Thanks for sharing your solution.
@@RobotResearchLab Apparently, the analog pins A6 and A7 explicitly can't be used for digital input: store.arduino.cc/usa/arduino-nano Go to the FAQ section. The more you know, I guess.
@@RobotResearchLab I'm now getting a problem with the sensor array where towards the zero end (the first/zeroth sensor), the readLineBlack() value starts to go up instead of down before becoming zero again. I am calibrating everything properly, and the output values for the calibration all seem normal (lowest is 48-192 and highest is 2500 across the board). This is again the second board I've had this problem with.
@@Mekadrom I would recommend running the raw values example to see if you get the same problem with your sensor toward the zero end. I've never seen that with just one sensor but I do know that I've seen issues with the library where the value will jump from 0 to 1023 because of an overflow problem. (Not sure if I mentioned that in this video but I mentioned it somewhere). Also, I'm not sure if you're using the QTR library from Pololu or the one I modified which is old and needs to be updated but still works if you aren't using the CTRL pins on the newer boards. If you're not using it, try my library here github.com/gberl001/qtr-sensors-arduino Lastly, if I don't respond to your message I apologize, TH-cam doesn't notify me of all comments for some reason so I never saw your comment about the A6 and A7 pins but that's very useful so thanks for sharing.
If you are using the QTR-8A (analog) then yes, you can only use up to 6 sensors. I would suggest just using the middle 6 and leave the outer two disconnected. Just know that this will change your PID "goal" value if you plan to implement PID. The goal is calculated by Goal=(numSensors-1)*1000/2 If that doesn't make sense just think about it from an intuitive point of view, you have 6 sensors, so the sensors will return somewhere between 0 (for the first sensor) and 5000 (the last sensor). You want to be in the middle so it's 5000/2 or 2500. And that's just because 2500 will be what the sensor returns when you are between the 3rd (2000) and fourth (3000) sensors. EmitterPin(2) is used if you want to be able to turn your sensors on and off. This can be helpful if you want to eliminate ambient light but I personally don't use it, I usually just put the sensor under the robot where it won't see much outside light or I cover the sensor with black electrical tape to block outside light from getting in. A calibration will typically fix any of this as well.
@@RobotResearchLabCould please help me... I'm preparing a line follower robot with arduino uno, L298n motor driver and QTR8 Digital... By the way this robot is not neither for a school project nor for competition, it's just for learning
@@motazmsaddak5242 Sure, that's what I'm here for, helping. Although it can be difficult to help remotely. You'll have to figure much of it out on your own (hopefully my videos can help) but I can help if you get stuck on something.
@@eyadkhirat413 If you were using the analog QTR-A array, the declaration would look something like this QTRSensorsAnalog qtrSensor((unsigned char[]) {A9, A8, A7, A6, A5, A4, A3, A2}, NUM_SENSORS, NUM_SAMPLES_PER_SENSOR, EMITTER_PIN); And if you wanted to use the digital QTR-RC array, that would look something like this QTRSensorsRC qtrSensor((unsigned char[]) {3, 4, 5, 6, 7, 8, 9, 10}, NUM_SENSORS, TIMEOUT, EMITTER_PIN); the rest of the code is the same. So for example, if you were taking a reading it would be: unsigned int position = qtrSensor.readLine(sensorValues); It's the same call for reading the line as long as you named the sensor the same thing like I did above where I called it qtrSensor, now it wouldn't matter if you're using the analog or digital, all the reading calls are the same, the only difference is when you declare it as QTRSensorsAnalog or QTRSensorsRC.
Great work brother!!!
Never seen anyone fixing a library.
I am wondering how did you come up with that solution at 18:15? It's really fascinating and saved me lots of time. I know it has been too much time since you release the video but if you remember what was the problem solving process you took I would be really appreciated. And even if you don't remember, can you tell me about what are your first steps to find the problem? (using debugger, reading code over and over etc.)
I am doing a line follower robot with qtr 8rc using the motor driver shield L293d model. I am not getting any calibration on screen, will u help me to fix it?
Sorry for the late reply, you can contact me through my site which will provide me with your email so I can contact you directly. Send me a message with your code and I'll definitely take a look. robotresearchlab.com/contact-me/
Hello sir! nice video! im just wondering if the qtrsensor library still works with a BFD-1000? I thought that it would still work since its just code but then you mentioned qtr sensor and its a qtr library... help me TT
I wanted to check out your source code, but the link you gave in the description is dead ): Has your blog article moved to a different location?
Sorry about that, somehow the link was shortened improperly. I updated the link in the description but here's the link here as well robotresearchlab.com/2019/03/18/how-to-hookup-and-program-a-qtr-8-sensor-array/ Thanks for checking out my work.
@@RobotResearchLab Great, thanks!
I have 2 questions-
1. What position value does the readLine function give when all the sensors are over a white surface?
2. What if I wanted to get the position of a white line on a black surface? Is there any function in the qtr sensors library which can give position of the white line between 0 to (no. Of sensors -1)*1000 just like you did with the black line?
Please help.I really learnt a lot from your videos
1. In theory, over an all white surface it would show the center as the result since each sensor would be weighted equally. However, this isn't really true since there is going to be some variance in the surface and in the calibration. Also, the library automatically accounts for when no sensor sees a line, it will return the first or last sensor (whichever last saw the line). So, to summarize, because of the way the library works, if you drive off the line going right, it will show 0, the left most sensor. If you drive off the line going left it will show the value of your right most sensor (7000 if you have 8 sensors).
2. This one's easy, the library can already handle this, there are two optional parameters for readLine(). In my code I just pass in the array which gets populated by the library with each sensor value. By default, the second parameter is QTR_EMITTERS_ON, and the third (which tells the library if it's white line) is set to false. All you have to do is provide these two optional parameters but change the last one to true so the library knows to look for a white line on dark background. It would look like this (not tested)
unsigned int position = qtrrc.readLine(sensorValues, QTR_EMITTERS_ON, true);
I hope that helps, thanks for watching and commenting.
Hello, I am using the QTR-8RC board and I followed this tutorial (including the soldering/wiring video) and I am not getting any values for the two sensors on the breakable part of the board. This is the second board where I've had this problem. Is there anything I need to do to enable the last two sensors?
Alright, so I figured it out not long after posting this. I am using this sensor with an Arduino nano. Normally, it is okay to use the analog pins for digital input (because digital input would just be either min analog or max analog input), and I made this choice because after hooking up the motor driver, I didn't have enough digital pins to use all digital pins for the sensor inputs. I fixed this by changing the last two sensor connections to my remaining two digital pins. The board works perfectly now.
@@Mekadrom Interesting, I've never seen this issue. All analog pins on Arduino boards should be able to be used as Digital. Maybe there is something with this particular library and Analog pins that doesn't mix well... Thanks for sharing your solution.
@@RobotResearchLab Apparently, the analog pins A6 and A7 explicitly can't be used for digital input: store.arduino.cc/usa/arduino-nano Go to the FAQ section. The more you know, I guess.
@@RobotResearchLab I'm now getting a problem with the sensor array where towards the zero end (the first/zeroth sensor), the readLineBlack() value starts to go up instead of down before becoming zero again. I am calibrating everything properly, and the output values for the calibration all seem normal (lowest is 48-192 and highest is 2500 across the board). This is again the second board I've had this problem with.
@@Mekadrom I would recommend running the raw values example to see if you get the same problem with your sensor toward the zero end. I've never seen that with just one sensor but I do know that I've seen issues with the library where the value will jump from 0 to 1023 because of an overflow problem. (Not sure if I mentioned that in this video but I mentioned it somewhere). Also, I'm not sure if you're using the QTR library from Pololu or the one I modified which is old and needs to be updated but still works if you aren't using the CTRL pins on the newer boards. If you're not using it, try my library here github.com/gberl001/qtr-sensors-arduino
Lastly, if I don't respond to your message I apologize, TH-cam doesn't notify me of all comments for some reason so I never saw your comment about the A6 and A7 pins but that's very useful so thanks for sharing.
Can I work only with 6 sensors because I'm using arduino UNO also I want to know what does it mean : "EmitterPin(2)"
If you are using the QTR-8A (analog) then yes, you can only use up to 6 sensors. I would suggest just using the middle 6 and leave the outer two disconnected.
Just know that this will change your PID "goal" value if you plan to implement PID. The goal is calculated by Goal=(numSensors-1)*1000/2
If that doesn't make sense just think about it from an intuitive point of view, you have 6 sensors, so the sensors will return somewhere between 0 (for the first sensor) and 5000 (the last sensor). You want to be in the middle so it's 5000/2 or 2500. And that's just because 2500 will be what the sensor returns when you are between the 3rd (2000) and fourth (3000) sensors.
EmitterPin(2) is used if you want to be able to turn your sensors on and off. This can be helpful if you want to eliminate ambient light but I personally don't use it, I usually just put the sensor under the robot where it won't see much outside light or I cover the sensor with black electrical tape to block outside light from getting in. A calibration will typically fix any of this as well.
@@RobotResearchLabCould please help me... I'm preparing a line follower robot with arduino uno, L298n motor driver and QTR8 Digital... By the way this robot is not neither for a school project nor for competition, it's just for learning
@@motazmsaddak5242 Sure, that's what I'm here for, helping. Although it can be difficult to help remotely. You'll have to figure much of it out on your own (hopefully my videos can help) but I can help if you get stuck on something.
Can you give me this code? Pls.
The sensor use in these is it QTR 8A or QTR 8RC ??
In the video I'm using QTR 8A, but QTR 8RC would work just as well. You'd just have to change the sensor declaration.
@@RobotResearchLab how I can do that?
@@eyadkhirat413 If you were using the analog QTR-A array, the declaration would look something like this
QTRSensorsAnalog qtrSensor((unsigned char[]) {A9, A8, A7, A6, A5, A4, A3, A2}, NUM_SENSORS, NUM_SAMPLES_PER_SENSOR, EMITTER_PIN);
And if you wanted to use the digital QTR-RC array, that would look something like this
QTRSensorsRC qtrSensor((unsigned char[]) {3, 4, 5, 6, 7, 8, 9, 10}, NUM_SENSORS, TIMEOUT, EMITTER_PIN);
the rest of the code is the same. So for example, if you were taking a reading it would be:
unsigned int position = qtrSensor.readLine(sensorValues);
It's the same call for reading the line as long as you named the sensor the same thing like I did above where I called it qtrSensor, now it wouldn't matter if you're using the analog or digital, all the reading calls are the same, the only difference is when you declare it as QTRSensorsAnalog or QTRSensorsRC.
Thank you👍👍