OBDuino Help

Fellas,

I am trying to get my OBDuino up and running and I think that I am really close. I am having some issues getting the buttons to work, but before I get into it, here's what I have...

Setup:

I am using the Sparkfun OBD-II UART and an Arduino Mega 2560. Running Windows 8.1, I was able to get Arduino 1.0.5 to load the drivers and compile the program, and successfully send it to the Arduino.

Results:

As of right now, the Arduino powers up, goes to its home screen, gets a good handshake with the Sparkfun UART and pulls data from the car's ECU. All of the data responds quickly to throttle inputs, and everything with the LCD screen seems to be working great.... right up until you go to hit the buttons to change the menu.

Problem:

None of the buttons work. I can't figure out why though. I did not change any of their coding in the program and I connected everything in accordance with this diagram:

The buttons that I am using are normally open and momentarily close the circuit when they are depressed.

Using the left button as an example, I have a wire going from "Analogue 3" on the Arduino to one of the leads on the switch. I have the other lead of the switch going to a wire which joins on one of the Arduino's ground posts. The continuity on the left button checks good on both leads when I set the multimeter to beep when it detects a short, and when I press the button, the Arduino's Analog 3 pin also has good continuity with the ground. The other two buttons are setup in the exact same fashion, but they are on A4 and A5.

What am I missing to get my buttons to work?

Thanks,

Pete

In setup(), do you have the buttons set up with pin mode(INPUT_PULLUP);? Or are you reading the buttons with analog read?

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:

// 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:

// 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:

|500x353

With the Arduino Mega 2560, it looks like Analog 3, 4, and 5 have different pin numbers?

|353x500

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

Hi, Where did you get the sketch from?

You say.

Sparkfun OBD-II UART and an Arduino Mega 2560

Yet, your diagram shows a UNO.

The pin allocations in the program certainly are not UNO.

Try this from the sparkfun site.

https://learn.sparkfun.com/tutorials/obd-ii-uart-hookup-guide/connecting-to-an-arduino

It uses the arduino uno like your diagram shows.

Tom.... :)

I got the sketch the code that I am using from the OBDuino project page from Google Code.

The project was originally coded and designed around the Uno, but I had a Mega available, which is why I attempted the project with that board instead of the Uno.

Is there anything that I can do with the code to make it run on the Mega?

Pete