04-29-2008, 09:28 AM
|
#41 (permalink)
|
needs more cowbell
Join Date: Feb 2008
Location: ÿ
Posts: 5,038
Thanks: 158
Thanked 269 Times in 212 Posts
|
Same thing, only tighten up the interrupt handler
doing digital reads in an interrupt seems kind of frowned on so I made ISR( PCINT1_vect ) as small as I could in this version. It does exactly the same thing as the previous post, just takes a litle more effort to move the pins around.
Code:
int lbuttonPin = 17; // Left Button, on analog 3,
int mbuttonPin = 18; // Middle Button, on analog 4
int rbuttonPin = 19; // Right Button, on analog 5
int lbuttonBit = 8; // pin17 is a bitmask 8 on port C
int mbuttonBit = 16; // pin18 is a bitmask 16 on port C
int rbuttonBit = 32; // pin19 is a bitmask 32 on port C
//pretend we start with upressed buttons
int buttonpins = lbuttonBit + mbuttonBit + rbuttonBit;
//attach the interrupt
ISR( PCINT1_vect ){
buttonpins &= PINC;//bypassing digitalRead for interrupt performance
}
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 enable stuff
PCICR |= (1 << PCIE1);
PCMSK1 |= (1 << PCINT11);
PCMSK1 |= (1 << PCINT12);
PCMSK1 |= (1 << PCINT13);
}
void loop() {
//print out what buttons have been pressed
if(!(buttonpins&lbuttonBit)) Serial.print("lbutton");
Serial.print(",");
if(!(buttonpins&mbuttonBit)) Serial.print("mbutton");
Serial.print(",");
if(!(buttonpins&rbuttonBit)) Serial.print("rbutton");
Serial.println("");
//reset the buttons
buttonpins = lbuttonBit + mbuttonBit + rbuttonBit;
delay(1000);
}
__________________
WINDMILLS DO NOT WORK THAT WAY!!!
|
|
|
Today
|
|
|
Other popular topics in this forum...
|
|
|
04-29-2008, 09:56 AM
|
#42 (permalink)
|
Batman Junior
Join Date: Nov 2007
Location: 1000 Islands, Ontario, Canada
Posts: 22,530
Thanks: 4,078
Thanked 6,978 Times in 3,613 Posts
|
Man, I'm falling behind (still haven't hooked up my LCD). But happy to see some code (buttons) that I can read at a glance. :P Thanks for commenting it nicely - I've collaborated on other projects before and people never seem to want to comment their stuff properly ("considerately" may be a better word).
|
|
|
05-01-2008, 01:19 AM
|
#43 (permalink)
|
needs more cowbell
Join Date: Feb 2008
Location: ÿ
Posts: 5,038
Thanks: 158
Thanked 269 Times in 212 Posts
|
update, the display has a 5x8 character box. It looks like there is 8 (not 16)user defined characters.
__________________
WINDMILLS DO NOT WORK THAT WAY!!!
Last edited by dcb; 05-01-2008 at 02:00 AM..
|
|
|
05-01-2008, 02:03 PM
|
#44 (permalink)
|
Master EcoModder
Join Date: Apr 2008
Location: Earth
Posts: 303
Thanks: 0
Thanked 8 Times in 4 Posts
|
One thing about non-tactile buttons...
In a car, they get old FAST. Touch screens and the like were cool when they first came out, but they're devoid of any tactile feedback. When I'm driving my car, I want to know that my input was received without having to look at whatever device I'm using. The car itself demands enough of my attention.
Another thing is that I may want to have my finger on the button without actually activating it. For example, on a CD player, if I am scanning through tracks, I want my finger to remain in the same place, but I want to hear a song for a few seconds before I skip it. With touch button, I have to withdraw my finger, then who knows where it's going to float off to with the motion in the car, vibration, etc. Plus holding your arm up in space isn't exactly comfortable. For my scangauge, I might want to reset my trip MPG as I pass a sign post. This requires that I know where my finger is and that I can activate the button at a precise moment, without having to look at it.
GPS devices have a good reason to use touch input. Stereos and MPG gauges do not.
/rant
|
|
|
05-01-2008, 08:37 PM
|
#45 (permalink)
|
needs more cowbell
Join Date: Feb 2008
Location: ÿ
Posts: 5,038
Thanks: 158
Thanked 269 Times in 212 Posts
|
Agreed about the buttons, especially if you want to have your finger on the button for doing some testing/calibration (i.e. hit it right when we pass this mile marker, etc).
__________________
WINDMILLS DO NOT WORK THAT WAY!!!
|
|
|
05-04-2008, 01:30 AM
|
#46 (permalink)
|
FuelSipper
Join Date: Mar 2008
Location: Dallas, TX
Posts: 99
Thanks: 0
Thanked 8 Times in 3 Posts
|
I'm not getting a warm fuzzy from my freeduino device and LCD. I tried firing it up again and it took several resets before I got it working again. Is this going to be typical after being off?
|
|
|
05-04-2008, 01:52 AM
|
#47 (permalink)
|
needs more cowbell
Join Date: Feb 2008
Location: ÿ
Posts: 5,038
Thanks: 158
Thanked 269 Times in 212 Posts
|
I've been trying to figure that one out, certainly don't want to leave it like that if it is possible to fix it, but it needs some research/trial and error. I *think* if we put the LCD power (and LED backlight) on a transistor and control the power up so that it is after the duino is up to speed that it might help, don't know for sure. The LCD stuff needs work. I want it to be solid, but there are probably a few folks besides me who could research it.
__________________
WINDMILLS DO NOT WORK THAT WAY!!!
|
|
|
05-04-2008, 02:16 AM
|
#48 (permalink)
|
Master EcoModder
Join Date: Apr 2008
Location: Earth
Posts: 303
Thanks: 0
Thanked 8 Times in 4 Posts
|
Got a capacitor on your 5v line? Regulators can only do so much to quiet the noise.
Simplify things...
LCD circuits use very little current. I've got mine powered off an AVR signal pin. With the right RC circuit, you can delay power to the LCD until your micro can stabilize its outputs.
|
|
|
05-04-2008, 08:50 AM
|
#49 (permalink)
|
needs more cowbell
Join Date: Feb 2008
Location: ÿ
Posts: 5,038
Thanks: 158
Thanked 269 Times in 212 Posts
|
The pin power for the LCD (not the LED!!) was a good idea, but no dice, not even with delays, and turning the LCD on and off.
I tried disconnecting the LED power while it booted up, no luck
It seems to boot up better if you hold down the reset button for two seconds, but hell if I'm certain about that or even know why.
The good news (or the bad news) is that it is reproduceable on seperate machines.
__________________
WINDMILLS DO NOT WORK THAT WAY!!!
|
|
|
05-04-2008, 10:43 AM
|
#50 (permalink)
|
FuelSipper
Join Date: Mar 2008
Location: Dallas, TX
Posts: 99
Thanks: 0
Thanked 8 Times in 3 Posts
|
|
|
|
|