We connected QTR Reflectance Sensors on pins PB0, PB1, PB2, PB4, PB5, PD2, PD4, PD7.
#include <pololu/orangutan.h>
char send_buffer[32];
unsigned int sensors[8]; // an array to hold sensor values
void wait_for_sending_to_finish()
{
while(!serial_send_buffer_empty());
}
void initialize()
{
// unsigned int counter; // used as a simple timer
// initialize your QTR sensors
unsigned char qtr_rc_pins[] = {8, 9, 10, 12, 13, 2, 4, 7};
qtr_rc_init(qtr_rc_pins, 8, 2000, 255); // 800 us timeout, no emitter pin
int i;
for (i = 0; i < 250; i++) // make the calibration take about 5 seconds
{
qtr_calibrate(QTR_EMITTERS_ON);
delay(20);
}
}
// This is the main function, where the code starts. All C programs
// must have a main() function defined somewhere.
int main()
{
serial_set_baud_rate(115200);
initialize();
while(1) {
qtr_read_calibrated(sensors, QTR_EMITTERS_ON);
wait_for_sending_to_finish();
serial_send(send_buffer, 8);
delay(5000);
}
}
I am getting all zeros in output. Any pointers?
PS: I have confirmed Sensor LED are ON by using a camera. LED are in always on state.
#include <pololu/orangutan.h>
char send_buffer[32];
unsigned int sensors[8]; // an array to hold sensor values
void wait_for_sending_to_finish()
{
while(!serial_send_buffer_empty());
}
void initialize()
{
// unsigned int counter; // used as a simple timer
// initialize your QTR sensors
unsigned char qtr_rc_pins[] = {8, 9, 10, 12, 13, 2, 4, 7};
qtr_rc_init(qtr_rc_pins, 8, 2000, 255); // 800 us timeout, no emitter pin
/* int i;
for (i = 0; i < 250; i++) // make the calibration take about 5 seconds
{
qtr_calibrate(QTR_EMITTERS_ON);
delay(20);
} */
}
// This is the main function, where the code starts. All C programs
// must have a main() function defined somewhere.
int main()
{
serial_set_baud_rate(115200);
initialize();
while(1) {
qtr_read(sensors, QTR_EMITTERS_ON);
wait_for_sending_to_finish();
serial_send(send_buffer, 8);
delay(5000);
qtr_read(sensors, QTR_EMITTERS_OFF);
wait_for_sending_to_finish();
serial_send(send_buffer, 8);
delay(5000);
}
}
Yes, we tried using bright white paper and dark black tape during calibration.
We also tried disabling calibration and reading from raw sensors (as in above code) but we are getting all zeros.