Go Back   EcoModder Forum > EcoModding > Instrumentation
Register Now
 Register Now
 

Reply  Post New Thread
 
Submit Tools LinkBack Thread Tools
Old 03-23-2015, 12:00 AM   #1 (permalink)
EcoModding Lurker
 
Join Date: Mar 2015
Location: Abilene, TX
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
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

  Reply With Quote
Alt Today
Popular topics

Other popular topics in this forum...

   
Old 03-25-2015, 02:23 AM   #2 (permalink)
EcoModding Lurker
 
Join Date: Mar 2015
Location: Abilene, TX
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
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

  Reply With Quote
Reply  Post New Thread


Tags
obduino help

Thread Tools




Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Content Relevant URLs by vBSEO 3.5.2
All content copyright EcoModder.com