Interfacing QTR-8RC with msp432 using CCS

Hello,
I am trying to interface the QTR-8RC sensor with a MSP432. I am always reading a zero from each sensor. I am using the following code to test it, Port 7 for the sensor pins, and Port 5.3 for the IR LED.

int i = 0;
SensorArray[0] = 0;
SensorArray[1] = 0;
SensorArray[2] = 0;
SensorArray[3] = 0;
SensorArray[4] = 0;
SensorArray[5] = 0;
SensorArray[6] = 0;
SensorArray[7] = 0;
SensorValue = 8;
P5 -> DIR |= 0x08; /* Make sure P5.3 is output /
P7 -> DIR |= 0xFF; /
Make sure P7 is output /
P5 -> OUT |= 0x08; /
Turn on LED /
P7 -> OUT |= 0xFF; /
Drive port 7 high /
usleep(780); /
Sleep for 10 useconds /
P7 -> DIR &= ~(0xFF); /
Change Port 7 to input /
P7 -> REN &= ~(0xFF); /
Turn off pull up resistors /
usleep(1);
for(i = 0; i < 16; i++)
{
SensorValue = (P7 -> IN & (1 << (i % 8)));
UART_PRINT(“pin value: %i \r\n”, (P7->IN & (1 << (i%8))));
UART_PRINT(“SensorValue: %i for pin: %i \r\n”, SensorValue, i);
SensorArray[i % 8] += SensorValue;
}
P5 -> OUT &= ~(0x08); /
Turn off LED */

16 was just to limit the amount of outputs I would get, but raising this number did not change the results. Any ideas on where to go?

Nevermind I figured it out. Sensor is working properly, I originally had a different pin for the LED and forgot to change it.

1 Like