Go Back   EcoModder Forum > EcoModding > Instrumentation > OpenGauge / MPGuino FE computer
Register
Now


Reply
 
Submit Tools LinkBack Thread Tools
Old 04-13-2008, 06:05 PM   #21 (permalink)
dcb
Master EcoModder
 
dcb's Avatar
 
Join Date: Feb 2008
Location: 3rd rock
Posts: 1,235

pimp mobile - '81 gs 250 t
90 day: 96.29 mpg (US)
Buttons

Here is a simple approach, can be had from the 'shack

needed:
1 bag of 4 surface mount push button switches . Mine were $2 though the site says $4
1 general purpose dual pc board ~$2

Some hookup wore (cut open an old network cable or something).

Hot Glue gun

that really thin solder helps, especially inbetween the buttons. And sharpen up your iron first. Tin the iron with solder as soon as it can melt it, before it gets too hot and oxidizes.

Assembly:
Find a 12x3 group of copper circles on the board, by the edge but not on the edge. Score through the next row out in all 4 directions and snap off the extra. Tin the circles lightly that you will be using.

X=tinned
XOOXXOOXXOOX
OOOOOOOOOOOO
XOOXXOOXXOOX

Starting with the middle switch (leads touching one X each), surface mount the switches to the tinned copper spots, don't let the switch leads touch the other switches on the bottom, but do solder bridge them on the top. That That will be the ground.

Hold your breath, and (CAREFULLY) grind the top and bottom flush on the grinding wheel, bring in the sides to just outside the rings where the switches are connected.

Add the wires (and leave yourself plenty of wire for now). Pull them through the plain side and bend them over an appropriate switch leg and solder. Attach three signal wires and one for the ground.

grind the extra solder and wire off the top/bottom/

Straighten out the wires and run them to one end

Feed the wires through the top right hole in the lcd and position the buttons so the metal part is flush with the front of the lcd and they are straight, and the right side is flush with the right of the lcd board.

Pull the buttons back out just enough to put a thin layer of hot glue on the bottom of the buttons, and quickly but accurately put them in their final position. If your happy with their position and protrusion from the lcd, squirt in (caulk style) some hotglue to fill in behind the button boar.


coding:
In your code, you can use the internal pullup resistors via:
pinMode(pin, INPUT); // set pin to input
digitalWrite(pin, HIGH); // turn on pullup resistors

then attachInterrpupt (pin, function, FALLING) and or with the "button has been pressed" flag.


Hookup, the ground goes to ground and the signals go to the pin they control.








(Support Ecomodder.com & get rid of these annoying ads!)      
 
  Reply With Quote
Old 04-13-2008, 06:16 PM   #22 (permalink)
dcb
Master EcoModder
 
dcb's Avatar
 
Join Date: Feb 2008
Location: 3rd rock
Posts: 1,235

pimp mobile - '81 gs 250 t
90 day: 96.29 mpg (US)
(EDIT, this is not current information)

Oh, and here is the LCD connection setup I used to preserve the multipurpose ports
Code:
NC=Not Connected

LCD pin	     16  15   14   13   12   11   10   9    8    7    6    5    4    3    2    1
Arduino Pin  GND 5V   13   12   8    7    NC   NC   NC   NC   4    6    0    5    5V   GND

Last edited by dcb; 05-05-2008 at 11:31 AM.
  Reply With Quote
Old 04-13-2008, 09:18 PM   #23 (permalink)
Captain Slow
 
MetroMPG's Avatar
 
Join Date: Nov 2007
Location: eastern Ontario
Posts: 5,458

Blackfly - '98 Metro
90 day: 80.17 mpg (US)

ForkenSwift - '92 Metro EV
90 day: 130.1 mpg (US)
Nice placement for those 3 buttons.
__________________
Latest test: Video: tuft testing front wheel skirts (Geo Metro)
Latest mod project:
basjoosing my headlight assembly gap




www.MetroMPG.com - fuel efficiency info for Geo Metro owners
www.ForkenSwift.com - electric car conversion on a beer budget
  Reply With Quote
Old 04-14-2008, 08:12 AM   #24 (permalink)
dcb
Master EcoModder
 
dcb's Avatar
 
Join Date: Feb 2008
Location: 3rd rock
Posts: 1,235

pimp mobile - '81 gs 250 t
90 day: 96.29 mpg (US)
FYI, dont take the pin assignments to seriously yet. The arduino has blocked external interrupts on most of the ports and it *might* require some rewiring.

I'm reading some things that say arduino only allows two external interrupts, and obviously we need those for the injector and the vss. the atmega can support lots more external interrupts, so it probably just needs a little digging, and dipping into AVR.

Last edited by dcb; 04-14-2008 at 08:29 AM.
  Reply With Quote
Old 04-14-2008, 09:46 AM   #25 (permalink)
dcb
Master EcoModder
 
dcb's Avatar
 
Join Date: Feb 2008
Location: 3rd rock
Posts: 1,235

pimp mobile - '81 gs 250 t
90 day: 96.29 mpg (US)
interrupt vectors
2 0x0002 INT0 External Interrupt Request 0
3 0x0004 INT1 External Interrupt Request 1
4 0x0006 PCINT0 Pin Change Interrupt Request 0
5 0x0008 PCINT1 Pin Change Interrupt Request 1
6 0x000A PCINT2 Pin Change Interrupt Request 2

arduino board mappings:
INT0 = digital pin 2
INT1 = digital pin 3
PCINT0= digital pin 8
PCINT1= digital pin 9
PCINT2= digital pin 10
PCINT3= digital pin 11
PCINT4= digital pin 12
PCINT5= digital pin 13

attachInterrupt only works with INT0 and INT1, so need to (INT0 example, translate for PCINT):
<chickenscratch>

#include <avr/interrupt.h>
...

int sensePin = 2;

...
ISR(INT0_vect) {
value = digitalRead(sensePin);
}
...
setup()
// Global Enable INT0 interrupt
GICR |= ( 1 < < INT0);
// Signal change triggers interrupt
MCUCR |= ( 1 << ISC00);
MCUCR |= ( 0 << ISC01);

}

</chickenscratch>

Don't know why there are not interrupt vectors for all the PCInts yet.

Note: in an ideal place we would use 6 external interrupts, 3 buttons, 1 injector signal, 1 vss signal, and one ignition power. But I recon we can poll the buttons and the ignition power if absolutely necessary.

Last edited by dcb; 04-14-2008 at 09:53 AM.
  Reply With Quote
Old 04-14-2008, 10:58 PM   #26 (permalink)
dcb
Master EcoModder
 
dcb's Avatar
 
Join Date: Feb 2008
Location: 3rd rock
Posts: 1,235

pimp mobile - '81 gs 250 t
90 day: 96.29 mpg (US)
Note: I Updated the pin assignments on the freeduino serial processor draft to just use pins 2 and 3 (INTR0 and INTR1), and those do seem to respond to the buttons anyway. I'm going to move LCD wire connected to Pin 2 to pin 0 and we can assure ourselves of VSS and Injector signals that way by reserving pins 2 and 3 respectively.

I think the guino should try and dip into AVR and get more interrupts going for the buttons though, it *should* be easier than polling, and less flakey. But if someone wants to come up with a "wait" that can guarantee one second accuracy on the main loop but still do things like poll buttons while it is "idle", then that is cool.
  Reply With Quote
Old 04-15-2008, 12:40 PM   #27 (permalink)
Emulating Jared
 
metroschultz's Avatar
 
Join Date: Dec 2007
Location: Virginia Beach, Va. USA
Posts: 588

SuperElasticBubblePlastic - '93 Metro plainjane
90 day: 51.46 mpg (US)

SilverHairBeauty - '01 Avalon XL
90 day: 24.06 mpg (US)

I'mL8I'mL8 - '99 Jetta GLS
90 day: 28.74 mpg (US)
Send a message via AIM to metroschultz
I'm still lurking,
waiting for a day when I would have something intelligent to add,
You guys are over my head, but I am patiently waiting the day you post schematics and parts list.
Thanx,
S.
__________________
I drive a piece 'o' Krap, so remember, "If you can't be handsome at least be handy"(Red Green).Schultz.

!!WooHoo I did it!! (now for the 55 MPG mark)
  Reply With Quote
Old 04-15-2008, 01:46 PM   #28 (permalink)
EcoModding Lurker
 
Join Date: Dec 2007
Location: Ventura, Ca
Posts: 70

Whoop's Wheels - '89 Civic Wagovan
90 day: 36.72 mpg (US)
Well I've made miniscule progress, but heh, progress. I've been waiting and watching every day for the board I ordered to come in. I finally went to the Post Office, multiple times and they told me the package had already been delivered, like a week earlier. I checked here in the office and nobody knows what I'm talking about.

Someone finally found the package mixed in with some magazines. I presumed it was in a box and it came in a plain white plastic padded bag, so it was just presumed to be a bag.

On the inputs, if we can run the injector and the speed inputs to interupt pins on the PC, that would be better than not. The problem on the injector is that we need to measure two things, relative to the signal. First, we need to measure how long the injector is on, each cycle and second, we need to measure how long it is before the next cycle, which will give us the frequency or period of time the cycles occur, each second. This is effectively, also the same number as the rpm, unless the car is coasting, in gear, injectors off.

The problem on the injector timing is that effectively we need to measure a falling edge signal, have timing to a leading edge and then have timing to the next falling edge. Generally on edge triggered inputs, you can set it up to do one, or the other, but not both, but I haven't gotten far enough to look into that, yet.
  Reply With Quote
Old 04-16-2008, 09:12 AM   #29 (permalink)
dcb
Master EcoModder
 
dcb's Avatar
 
Join Date: Feb 2008
Location: 3rd rock
Posts: 1,235

pimp mobile - '81 gs 250 t
90 day: 96.29 mpg (US)
Quote:
Originally Posted by Whoops View Post
Generally on edge triggered inputs, you can set it up to do one, or the other, but not both, but I haven't gotten far enough to look into that, yet.
on the ATMega, there is an interrupt mode called "CHANGE", which gets triggered on high2low and on low2high. We probably need to use that one and do a digitalRead(injPin) first thing in the interrupt, or otherwise toggle a flag, or both. I should probably reference this from the signal processing thread.

Last edited by dcb; 04-16-2008 at 09:27 AM.
  Reply With Quote
Old 04-16-2008, 10:03 AM   #30 (permalink)
Captain Slow
 
MetroMPG's Avatar
 
Join Date: Nov 2007
Location: eastern Ontario
Posts: 5,458

Blackfly - '98 Metro
90 day: 80.17 mpg (US)

ForkenSwift - '92 Metro EV
90 day: 130.1 mpg (US)
Quote:
Originally Posted by dcb View Post
In your code, you can use the internal pullup resistors via:
pinMode(pin, INPUT); // set pin to input
digitalWrite(pin, HIGH); // turn on pullup resistors
A little OT (and revealing my noobness on the topic)....

1) I didn't know what a pull up/down resistor was until recently.

2) This simple tutorial shows an external pull up resistor in a test button circuit. http://www.arduino.cc/en/Tutorial/Button

So ... the external resistor isn't strictly needed for that tutorial?
__________________
Latest test: Video: tuft testing front wheel skirts (Geo Metro)
Latest mod project:
basjoosing my headlight assembly gap




www.MetroMPG.com - fuel efficiency info for Geo Metro owners
www.ForkenSwift.com - electric car conversion on a beer budget
  Reply With Quote
Old 04-16-2008, 10:12 AM   #31 (permalink)
dcb
Master EcoModder
 
dcb's Avatar
 
Join Date: Feb 2008
Location: 3rd rock
Posts: 1,235

pimp mobile - '81 gs 250 t
90 day: 96.29 mpg (US)
Quote:
Originally Posted by MetroMPG View Post
So ... the external resistor isn't strictly needed for that tutorial?
Absolutely correct If your button is connecting the pin to ground, then no it isn't needed. Save your self a component and use the built in pullup resistor.
  Reply With Quote
Old 04-16-2008, 10:20 AM   #32 (permalink)
Captain Slow
 
MetroMPG's Avatar
 
Join Date: Nov 2007
Location: eastern Ontario
Posts: 5,458

Blackfly - '98 Metro
90 day: 80.17 mpg (US)

ForkenSwift - '92 Metro EV
90 day: 130.1 mpg (US)
OK - thanks.
__________________
Latest test: Video: tuft testing front wheel skirts (Geo Metro)
Latest mod project:
basjoosing my headlight assembly gap




www.MetroMPG.com - fuel efficiency info for Geo Metro owners
www.ForkenSwift.com - electric car conversion on a beer budget
  Reply With Quote
Old 04-16-2008, 09:13 PM   #33 (permalink)
Captain Slow
 
MetroMPG's Avatar
 
Join Date: Nov 2007
Location: eastern Ontario
Posts: 5,458

Blackfly - '98 Metro
90 day: 80.17 mpg (US)

ForkenSwift - '92 Metro EV
90 day: 130.1 mpg (US)
Quote:
Originally Posted by dcb View Post
Sorry, I couldn't resist playing with the lcd. The library didn't work for me, wound up poking at it in arduino ide till I got somewhere.
My LCD arrived today.

Can you point me in the right direction (links?) to play around with it? It sounds from your experience like it's not straightforward.
__________________
Latest test: Video: tuft testing front wheel skirts (Geo Metro)
Latest mod project:
basjoosing my headlight assembly gap




www.MetroMPG.com - fuel efficiency info for Geo Metro owners
www.ForkenSwift.com - electric car conversion on a beer budget
  Reply With Quote
Old 04-17-2008, 12:16 AM   #34 (permalink)
dcb
Master EcoModder
 
dcb's Avatar
 
Join Date: Feb 2008
Location: 3rd rock
Posts: 1,235

pimp mobile - '81 gs 250 t
90 day: 96.29 mpg (US)
Well, I didn't get anywhere with the 4 bit library, and it was getting annoying recompiling the library for a bunch of trial and error, so I tried this:
http://www.arduino.cc/cgi-bin/yabb2/...m=1160586800/0

I didn't get results at first and don't recall everything that was involved (predefined timings was one of the gotchas). But here are my current pin assignments and the mpguino display code. It does a good job of highlighting the sequence of events but the delays do need to be redone as status checks and pushed back into the lcd library. Note, with this code I had to hit the reset button after downloading the script or powering up sometimes.
Code:
LCD	arduino
1	ground
2	5v
3	digital 6
4	digital 4
5	digital 0
6	digital 5
7	not connected
8	not connected
9	not connected
10	not connected
11	digital 7
12	digital 8
13	digital 12
14	digital 13
15	5v
16	ground
Code:
int DI = 4; // register select RS
int RW = 0; 

int db4=7; int db5=8; int db6=12; int db7=13;
int contrast=6;
int Enable = 5; 
 
 
void tickleEnable() 
{ 
 // send a pulse to enable 
 digitalWrite(Enable,HIGH); 
 delayMicroseconds(1);  // pause 1 ms according to datasheet 
 digitalWrite(Enable,LOW); 
 delayMicroseconds(1);  // pause 1 ms according to datasheet 
}  
 
void cmdWriteSet() 
{ 
 digitalWrite(Enable,LOW); 
 delayMicroseconds(1);  // pause 1 ms according to datasheet 
  digitalWrite(DI,0); 
  digitalWrite(RW,0); 
} 
void LcdCommandWrite(int value)  
{ 
 int i = 0; 
 
    digitalWrite(db7, value & 128); 
    value <<= 1; 
    digitalWrite(db6, value & 128); 
    value <<= 1; 
    digitalWrite(db5, value & 128); 
    value <<= 1; 
    digitalWrite(db4, value & 128); 
    value <<= 1; 
    cmdWriteSet(); 
    tickleEnable(); 

    digitalWrite(db7, value & 128); 
    value <<= 1; 
    digitalWrite(db6, value & 128); 
    value <<= 1; 
    digitalWrite(db5, value & 128); 
    value <<= 1; 
    digitalWrite(db4, value & 128); 
     value <<= 1; 
    cmdWriteSet(); 
    tickleEnable(); 
} 
 
void LcdDataWrite(int value)  
{ 
 int i = 0; 
  
 digitalWrite(DI, HIGH); 
 digitalWrite(RW, LOW); 
   
    digitalWrite(db7, value & 128); 
    value <<= 1; 
    digitalWrite(db6, value & 128); 
    value <<= 1; 
    digitalWrite(db5, value & 128); 
    value <<= 1; 
    digitalWrite(db4, value & 128); 
  value <<= 1; 

    tickleEnable(); 
 
    digitalWrite(db7, value & 128); 
    value <<= 1; 
    digitalWrite(db6, value & 128); 
    value <<= 1; 
    digitalWrite(db5, value & 128); 
    value <<= 1; 
    digitalWrite(db4, value & 128); 
value <<= 1; 
    tickleEnable(); 
    delay(5);
} 
 
void setup (void)  
{ 
 pinMode(Enable,OUTPUT); 
 pinMode(RW,OUTPUT); 
 pinMode(DI,OUTPUT); 
 pinMode(db4,OUTPUT); 
 pinMode(db5,OUTPUT); 
 pinMode(db6,OUTPUT); 
 pinMode(db7,OUTPUT); 
 
 delay(100); 
 LcdCommandWrite(0x2c);  // function set: 
  delay(64);             // 4-bit interface, 2 display lines, 5x7 font 
                        // other interaces: 
                        // 0x20 = 4 bit, 1 display line 
 
 LcdCommandWrite(0x06);  // entry mode set: 
                        // increment automatically, no display shift 
 delay(20);                       
 LcdCommandWrite(0x0c);  // display control: 
                        // turn display on, cursor on, no blinking 
 delay(20);                       
 LcdCommandWrite(0x01);  // clear display, set cursor position to zero   
 
 delay(100);                       
LcdCommandWrite(0x80);  // set dram to zero (necessary?
 delay(20);       

 analogWrite(contrast,75);
 delay(20);       

} 
  int i='0';
 
void loop (void)  
{ 
   
  delay(500);                  // stop the program for some time 

  LcdCommandWrite(0x01);  // set cursor position to zero   
  delay(20);                      
  firstDisplay(); 
 
boolean asc=true;
  while(true){
    for(int x = 0; x < 256; x++){
     analogWrite(contrast,x);
     delay(8);
    }
    for(int x = 255; x >0; x--){
     analogWrite(contrast,x);
     delay(8);
    }
  };
} 
 


void firstDisplay() 
{ 
//     LcdDataWrite(value); 
     LcdDataWrite('O'); 
     LcdDataWrite('P'); 
     LcdDataWrite('E'); 
     LcdDataWrite('N'); 
     LcdDataWrite('G'); 
     LcdDataWrite('A'); 
     LcdDataWrite('U'); 
     LcdDataWrite('G'); 
     LcdDataWrite('E'); 
LcdCommandWrite(0xC9);  // C0 would be start of second line
 delay(20);       

     LcdDataWrite('M'); 
     LcdDataWrite('P'); 
     LcdDataWrite('G'); 
     LcdDataWrite('U'); 
     LcdDataWrite('I'); 
     LcdDataWrite('N'); 
     LcdDataWrite('O'); 
 }

Last edited by dcb; 04-17-2008 at 12:23 AM.
  Reply With Quote
Old 04-17-2008, 08:44 AM   #35 (permalink)
dcb
Master EcoModder
 
dcb's Avatar
 
Join Date: Feb 2008
Location: 3rd rock
Posts: 1,235

pimp mobile - '81 gs 250 t
90 day: 96.29 mpg (US)
Here is a data sheet on the LCD controller. The LCD itself has a 5x10 character format.
http://www.electronic-engineering.ch...cd/hd44780.pdf

One of the possible tweaks might be to create custom characters that use the whole 5x8 character box. They could be larger numbers perhaps for easier reading or maybe custom characters to conserve display real estate , i.e. MPG might have this in front of it instead of three characters:
(Note, just realized the lcd is 5x8, not 5x10!!!)

(just using paintbrush at 800% zoom)

I don't know how many user defined characters are on this display yet, however.

Last edited by dcb; 04-30-2008 at 11:59 PM. Reason: changed 5x10 to 5x8
  Reply With Quote
Old 04-21-2008, 11:23 PM   #36 (permalink)
FuelSipper
 
Join Date: Mar 2008
Location: Dallas, TX
Posts: 88

HondaHokie - '95 Accord DX 4 door
90 day: 30.92 mpg (US)
I've gotten my LCD to work. It actually is a pretty nice display. Can't wait to see it posting some real data. dcb, i like the little fading feature you setup in the code.
__________________

Last edited by larrydag; 04-21-2008 at 11:30 PM.
  Reply With Quote
Old 04-22-2008, 07:27 AM   #37 (permalink)
dcb
Master EcoModder
 
dcb's Avatar
 
Join Date: Feb 2008
Location: 3rd rock
Posts: 1,235

pimp mobile - '81 gs 250 t
90 day: 96.29 mpg (US)
Very Cool

The only thing to add to it is LCD pin 15 (Backlight power) should probably be controlled by an arduino pin and a transistor, so you can controll the brightness from a menu option, and turn off the LED when the ignition is off.
  Reply With Quote
Old 04-22-2008, 09:05 AM   #38 (permalink)
FuelSipper
 
Join Date: Mar 2008
Location: Dallas, TX
Posts: 88

HondaHokie - '95 Accord DX 4 door
90 day: 30.92 mpg (US)
Do you mean turn off the LCD when the ignition is off? I assume you mean that you would want a pin to turn off the LCD when you want to release the keys from the igninition. Otherwise you want the LCD to stay on when you cut the engine during P&G'ing. Is this correct?

Otherwise why not use a power source from the car that cuts off when the keys are in the OFF position.
__________________

Last edited by larrydag; 04-22-2008 at 09:12 AM.
  Reply With Quote
Old 04-22-2008, 08:29 PM   #39 (permalink)
dcb
Master EcoModder
 
dcb's Avatar
 
Join Date: Feb 2008
Location: 3rd rock
Posts: 1,235

pimp mobile - '81 gs 250 t
90 day: 96.29 mpg (US)
You have a point about the key, I had kill switch in my head so it didn't occur to me that folks might be turning off the ignition.

I need to list out my assumptions I think.

1. The arduino is powered by battery power. Because:
A. there are a limited number of eeprom writes, the trips should be saved when the key is turned off, but the arduino can't do that if you are turning off it's power also.

B. there are some sleep modes for the arduino that it could utilize when the ignition is off, but I don't think the drain will be terribly noticable.

2. The arduino should sense the ignition power, Because:
A. it needs to write out the current state of the trips to the eeprom on the ignition off event.

B. If the arduino has control of the LED Backlight (i.e. fancy schmancy menu brightness option) it can turn it off on the ignition off event and save ~200 milliamps. This adds one component (transistor) to the design. Switching it with the ignition directly will add one component in the form of a resistor to limit the current, and not give user control.

So I was thinking have the arduino turn off the LED, since the arduino was already connected to ignition power (in my head) and it was a simple task to have a menu driven brightness. The LCD only takes about ~4ma so I'm not worried about it yet.

But, maybe, it just has to be a (hokey) delay thing. Like if the car hasnt shown any rpm or travelled any distance in, say, 10 minutes, then it saves the trips in their 10 minutes ago state, and turns off the backlight? Saves us a ignition power pin.
  Reply With Quote
Old 04-28-2008, 11:18 PM   #40 (permalink)
dcb
Master EcoModder
 
dcb's Avatar
 
Join Date: Feb 2008
Location: 3rd rock
Posts: 1,235

pimp mobile - '81 gs 250 t
90 day: 96.29 mpg (US)
button interrupts have been sorted out.

Phew, finally got the buttons to be read reliably with interrupts in arduino IDE. No polling required, though we might want to elaborate on the debouncing at some point. This also means there are a lot more pins for doing external interrupts with than arduino allows "out of the box", though only pins 2&3 do RISING/FALLING, the rest are state change, not a big deal.


Code:
#include <avr/interrupt.h>    
#include <avr/io.h>  

int lbuttonPin = 17; // Left Button, on analog 3 
int mbuttonPin = 18; // Middle Button, on analog 4 
int rbuttonPin = 19; // Right Button, on analog 5 

//button signals are inverted (internal pullup resistor), so true is not pressed
boolean  lbutton = true;
boolean  mbutton = true;
boolean  rbutton = true;
 
//attach the interrupt 
ISR( PCINT1_vect ){ 
  PCICR &= !(1 << PCIE1);//disable interrupts in the interrupt
  if (!digitalRead(lbuttonPin)) lbutton = false;
  if (!digitalRead(mbuttonPin)) mbutton = false;
  if (!digitalRead(rbuttonPin)) rbutton = false;
  PCICR |= (1 << PCIE1);
} 
 
void setup() { 
  Serial.begin(9600);
  pinMode( lbuttonPin, INPUT ); 
  pinMode( mbuttonPin, INPUT ); 
  pinMode( rbuttonPin, INPUT ); 

//"turn on" the internal pullup resistors
  digitalWrite( lbuttonPin, HIGH); 
  digitalWrite( mbuttonPin, HIGH); 
  digitalWrite( rbuttonPin, HIGH); 

//low level interrupt stuff
  PCICR |= (1 << PCIE1); 
  PCMSK1 |= (1 << PCINT11); 
  PCMSK1 |= (1 << PCINT12); 
  PCMSK1 |= (1 << PCINT13);   
} 
 
void loop() {    
  //print out what buttons have been pressed
  if(!lbutton) Serial.print("lbutton");
  Serial.print(",");
  if(!mbutton) Serial.print("mbutton");
  Serial.print(",");
  if(!rbutton) Serial.print("rbutton");
  Serial.println("");
  
  //reset the buttons
  lbutton = true;
  mbutton = true;
  rbutton = true;
  
  delay(500);
}
  Reply With Quote