Hello,
I have a teensy 3.1 and a sensor QTR-8A. I want to retrieve the values ??of the sensor on a serial port
screen about the subject :
http://www.hostingpics.net/viewer.php?id=995235serial.png
I tried to power the VCC pin to 5V and 3.3V with the same conclusion. I also tried to fed 3.3V pin side of the BYPASS pin but the LEDs are not supplied in these conditions.
This is my code:
#define numSensors 5
#define maxValue 4000
unsigned char pins[] = {0, 1, 2, 3, 4};
unsigned int sensor_values[numSensors];
void readSensors()
{
unsigned char i;
for(i = 0; i < numSensors; i++)
{
sensor_values = maxValue;
_ digitalWrite(pins*, HIGH); // make sensor line an output*_
_ pinMode(pins*, OUTPUT); // drive sensor line high*
* }
delayMicroseconds(10); // charge lines for 10 us*
* for(i = 0; i < numSensors; i++)
{
pinMode(pins, INPUT); // make sensor line an input*
* }
unsigned long startTime = micros();
while (micros() - startTime < maxValue)
{
unsigned int time = micros() - startTime;
for (i = 0; i < numSensors; i++)
{_
if (digitalRead(pins) == LOW && time < sensor_values)
sensor_values = time;
_ }
}
}
void setup()
{
Serial.begin(9600);
}
void loop()
{
unsigned char i;
readSensors();
for (i = 0; i < numSensors; i++)
{_
Serial.print(sensor_values);
_ Serial.print(" ");
}
delay(1000);
Serial.println();
}
Thank You.
*_