You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed that there was not support for the Raspberry Pi Pico and I stated implementing it. I have tested Digital I/O, Analog Out and Servo so far. However I hit a roadblock with Analog Inputs. This is what I have so far:
The problem seems to be that in the Raspberry Pi Pico reading the ADC0 needs to be done by reading the pin 26 analogRead(26). But in the StandarFirmata.ino the macro PIN_TO_ANALOG is used to get the corresponding analog pin counting from zero (A0). Here is the corresponding code:
/* ANALOGREAD - do all analogReads() at the configured sampling interval */
for (pin = 0; pin < TOTAL_PINS; pin++) {
if (IS_PIN_ANALOG(pin) && Firmata.getPinMode(pin) == PIN_MODE_ANALOG) {
analogPin = PIN_TO_ANALOG(pin);
if (analogInputsToReport & (1 << analogPin)) {
Firmata.sendAnalog(analogPin, analogRead(analogPin));
}
}
}
With the macro as I have defined it (PIN_TO_ANALOG(p) ((p) - 26)), for pin 26 it calls analogRead(0) which is incorrect. If I change the code to be as follows:
I noticed that there was not support for the Raspberry Pi Pico and I stated implementing it. I have tested Digital I/O, Analog Out and Servo so far. However I hit a roadblock with Analog Inputs. This is what I have so far:
The problem seems to be that in the Raspberry Pi Pico reading the
ADC0
needs to be done by reading the pin 26analogRead(26)
. But in the StandarFirmata.ino the macroPIN_TO_ANALOG
is used to get the corresponding analog pin counting from zero (A0). Here is the corresponding code:With the macro as I have defined it (
PIN_TO_ANALOG(p) ((p) - 26)
), for pin 26 it callsanalogRead(0)
which is incorrect. If I change the code to be as follows:if works fine and I'm able to read the analog pins.
I tried changing the macros to be as follows:
I was hoping to get the code to call
analogRead(26)
but it does not work. I guess that it is becauseTOTAL_ANALOG_PINS
need to be maximum 16.Is there a way of fixing this without needing to modify the StandarFirmata code?
The text was updated successfully, but these errors were encountered: