I think I figured out something that could have been causing the issue. In all honesty, I did not write the code, only trying to get it to work in my project. This is my first Arduino project, so I think I am in a little bit over my head.
Here's the code where the buttons are declared:
Code:
// use analog pins as digital pins for buttons
#define lbuttonPin 17 // Left Button, on analog 3
#define mbuttonPin 18 // Middle Button, on analog 4
#define rbuttonPin 19 // Right Button, on analog 5
#define lbuttonBit 8 // pin17 is a bitmask 8 on port C
#define mbuttonBit 16 // pin18 is a bitmask 16 on port C
#define rbuttonBit 32 // pin19 is a bitmask 32 on port C
#define buttonsUp 0 // start with the buttons in the 'not pressed' state
byte buttonState = buttonsUp;
// Easy to read macros
#define LEFT_BUTTON_PRESSED (buttonState&lbuttonBit)
#define MIDDLE_BUTTON_PRESSED (buttonState&mbuttonBit)
#define RIGHT_BUTTON_PRESSED (buttonState&rbuttonBit)
And later in the code, here's more on them:
Code:
// buttons init
pinMode(lbuttonPin, INPUT);
pinMode(mbuttonPin, INPUT);
pinMode(rbuttonPin, INPUT);
// "turn on" the internal pullup resistors
digitalWrite(lbuttonPin, HIGH);
digitalWrite(mbuttonPin, HIGH);
digitalWrite(rbuttonPin, HIGH);
Originally though, I think OBDuino was written for an Arduino Uno. In the code, pins 17, 18 and 19 correspond to Analog 3, 4, and 5 in this diagram, which matches the schematic below and in my original post for OBDuino:
With the Arduino Mega 2560, it looks like Analog 3, 4, and 5 have different pin numbers?
I am not sure exactly if there is a difference in the pinouts or what I need to do to the code to make it work. As it is right now, I have tried with my buttons as depicted in the schematic in the original post, on my Mega's Analog 3, 4 and 5; and also tried on the Mega's Digital 33, 34, and 35. Neither configuration worked...
Any advice?
Pete