buongiorno =) stavo seguendo questa guida Pololu - Arduino Library for the Pololu QTR Reflectance Sensors per far funzionare 2 sensori di linea , e chiaramente l ho un po modificata per le mie necessità , al caricamento del programma però mi da una marea di errori che la libreria dovrebbe aver risolto
gli errori che mi da sono questi
sketch_apr13a:5: error: 'QTRSensorRC' does not name a type
sketch_apr13a:5: error: expected unqualified-id before ',' token
sketch_apr13a:5: error: expected unqualified-id before numeric constant
sketch_apr13a.ino: In function 'void setup()':
sketch_apr13a:14: error: 'qtr' was not declared in this scope
sketch_apr13a.ino: In function 'void loop()':
sketch_apr13a:27: error: 'qtr' was not declared in this scope
il mio programma è questo
#include <QTRSensors.h>
int motoreSX = 3;
int motoreDX = 4;
QTRSensorRC qtr((char[]){ 11, 5 },2);
void setup ()
{
pinMode (motoreDX , OUTPUT);
pinMode (motoreSX , OUTPUT);
int i;
for (i = 0; i < 250; i++)
{
qtr.calibrate();
delay(20);
}
}
void loop()
{
digitalWrite ( motoreDX , HIGH);
digitalWrite ( motoreSX , HIGH);
unsigned int sensors[2];
// get calibrated sensor values returned in the sensors array, along with the line position
// position will range from 0 to 2000, with 1000 corresponding to the line over the middle sensor
int position = qtr.readLine(sensors);
int error = position - 1000;
if (error < -500) // the line is on the left
digitalWrite ( motoreDX , LOW); // turn left
if (error > 500) // the line is on the right
digitalWrite ( motoreSX , LOW); // turn right
}
grazie a tutti