Hello Group!
I recently purchased some new QTRX-RC sensors from Pololu and I used their Arduino library to use the sensors and their examples work fine. Now I have a question. I am trying to turn on an LED and then turn it back off. I am having some difficulty in doing so. The code is below. I tried reading the values and creating a threshhold however that failed to work.
#include <QTRSensors.h>
#define NUM_SENSORS 2
#define TIMEOUT 2500
#define EMITTER_PIN QTR_NO_EMITTER_PIN
QTRSensorsRC qtrrc((unsigned char[]) {3, 4},
NUM_SENSORS, TIMEOUT, EMITTER_PIN);
unsigned int sensorValues[NUM_SENSORS];
void setup() {
delay(500);
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
for (int i = 0; i < 400; i++) {
qtrrc.calibrate();
}
digitalWrite(13, LOW);
Serial.begin(9600);
for (int i = 0; i < NUM_SENSORS; i++) {
Serial.print(qtrrc.calibratedMinimumOn[i]);
Serial.print(' ');
}
Serial.println();
for (int i = 0; i < NUM_SENSORS; i++) {
Serial.print(qtrrc.calibratedMaximumOn[i]);
Serial.print(' ');
}
Serial.println();
Serial.println();
delay(1000);
}
void loop() {
qtrrc.read(sensorValues);
for (unsigned char i = 0; i < NUM_SENSORS; i++) {
Serial.print(sensorValues[i]);
Serial.print('\t');
}
Serial.println();
delay(250);
}
How would I write the code to turn an LED on or OFF? This code is from their own Arduino Library. Thanks for the help!