I have gone out of my way and ordered this time another sensor, the pololu QTR-8RC. Because this schoolproject is driving me crazy. I have been working non stop on this project and have tried all codes there are to find on the internet.
As you can see I have three microcontrollers, two uno's and one mega. I checked these microcontrollers and they work fine, a few days ago I used these for another project (controlling servo's and bluetooth communication). So I don't think my microcontrollers are an issue.
I am using sensor 2,3,4,5,6 and 7. Sensor 2 is connected to A0, sensor 3 to A1, sensor 4 to A2, sensor 5 to A3, sensor 6 to A4, sensor 7 to A5.
Could you check this in the code if this alright or the order should be switched or something?
I also don't uderstand where you can declare exactly wich sensor is atatched to wich pin. I can see that you have to specify the number of sensor and wich inputs are used, but I don't see it specified exactly.
The motors also work correctly, if use the DRV8835 library and use the test code, both motors are turning in the right direction as specified. BTW I am using two lithium-ion 18650 batteries (wich should provide more than enough current). They are brand new, so no issue there.
Edit: I have now used the serial monitor to check the QTR-8RC and as far as I can see it works fine, it show a value around 200-300 if a black line is detected and a value around 10 if white background is detected.
But again no succes with line following.
And I am not sure If I should define the analog pins A0 to A5 as inputs, as they are receiving values from the QTR sensor.
Also if declaring the pins in the beginning, should I refer to the analog pins like I did now i.e. 14, 15,.... or just A0,A1,A2....?