Romi 32U4 Control Board Pin 12 always low

Hi

I am testing Romi 32U4 Control Board by connecting IR Obstacle Avoidance Sensor ( http://www.electrodragon.com/product/infraredir-obstacle-avoidance-sensor-moduleadjust-distance/) to free GPIO pins and reading values.

Out of 8 free pins ( 0, 1, 5, 12, A0, A2, A3, and A4 ), 7 pins ( 0, 1, 5, A0, A2, A3, and A4 ) are working correctly but
pin 12’s voltage is always 0 and not working.

I checked the voltage of pin 12 without connecting sensor and it’s 0V, (other free pins are about 5V)
When I connect the sensor to pin 12, the indicator of the sensor goes immediately 0 and is always 0 regardless of the sensing state.

The user guide says the following but I am not sure if it’s related to my case.

Pin 5 (PC6) is a hardware PWM output and is usable with the Arduino analogWrite() function. Pin 12 (A11/PD6) can also be used as a PWM output, but it is not supported by analogWrite(), and using pin 12 for PWM might conflict with uses of pin 6 (which controls the buzzer by default) as these two pins are complementary outputs of Timer4 channel D.

Pins 12 (A11/PD6), A0 (18/PF7), A2 (20/PF5), A3 (21/PF4), and A4 (22/PF1) can be used as analog inputs.

Do I need to configure something for the pin 12?

Thanks in advance

Hello.

Pin 12 should not require any special configuration and there are no onboard peripherals that use it. Are you initializing it as a digital input? Have you tried to disconnect the sensor and initialize that pin to use the internal pullup resistor or as an output (with a digital write) to see if it changes state?

-Nathan

Hello Nathan

Thank you for the advice.

After using the pin as output to see if its state change, the problem seems to have resolved by itself.

For the record, I was originally using FastGPIO library to set up input

FastGPIO::Pin<12>::setInputPulledUp();
FastGPIO::Pin<12>::isInputHigh();

And after your commend I also tried Arduino’s standard way

pinMode(12, INPUT_PULLUP);
digitalRead(12);

but this didn’t work either.

After using the pin as output as follow, however, it started working.

void setup() {
  pinMode(12, OUTPUT);
}

void loop() {
  digitalWrite(12, HIGH);
  Serial.println(digitalRead(12));
  digitalWrite(12, LOW);
  Serial.println(digitalRead(12));
}

I am not sure what was wrong, but now it’s working.

Thank you very much. :grin:

Moto

I am glad to hear it is working. Thanks for letting me know.

-Nathan