I need to redefine the A0 - A3 ports to analog inputs. I tried to just do
pinMode(A0, INPUT); pinMode(A1, INPUT); pinMode(A2, INPUT); pinMode(A3, INPUT);
…at the end of setup() and the just do
a0 = analogRead(A0);
…but I only got zero from the port.
When I wrote a completely separate sketch (without the Arduboy library, just something for the Leonardo), I got perfect readings from the ports. I probably need to change something in the library to make this work with the rest of the Arduboy lib. Where exactly can I find the important routines for the button pins?
This video shows how it works. I have a 10k pullup resistor. And I have this conductive plastic foam pulling down. Since the RGB LED has a common anode, the catodes go to the PWM pins to sink the current. The harder press on the foam, the lower voltage on the analog pins, the brighter led.
pins_arduino.h I found this:
// Mapping of analog pins as digital I/O // A6-A11 share with digital pins #define PIN_A0 (18) #define PIN_A1 (19) #define PIN_A2 (20) #define PIN_A3 (21) #define PIN_A4 (22) #define PIN_A5 (23) #define PIN_A6 (24) #define PIN_A7 (25) #define PIN_A8 (26) #define PIN_A9 (27) #define PIN_A10 (28) #define PIN_A11 (29) static const uint8_t A0 = PIN_A0; static const uint8_t A1 = PIN_A1; static const uint8_t A2 = PIN_A2; static const uint8_t A3 = PIN_A3; static const uint8_t A4 = PIN_A4; static const uint8_t A5 = PIN_A5; static const uint8_t A6 = PIN_A6; // D4 static const uint8_t A7 = PIN_A7; // D6 static const uint8_t A8 = PIN_A8; // D8 static const uint8_t A9 = PIN_A9; // D9 static const uint8_t A10 = PIN_A10; // D10 static const uint8_t A11 = PIN_A11; // D12
Would this be the right place to disable the redefining of analog pins? If I just comment out all lines with A0 to A3?
I do know that I would disable my Arduboy to work with standard Arduboy software, but this is a prototype for a new concept. Later on I’ll figure out how to get it work with standard Arduboy games.