Go Down

Topic: get shiftin data with interrupt (Read 745 times) previous topic - next topic

iam_peter

hello,

i build the Parallel to Serial Shifting-In with a CD4021BE from the arduino tutorials http://www.arduino.cc/en/Tutorial/ShiftIn.
now the question is: "can i call an interrupt on pressing a button?"
i want to make a keyboard out of this to control the frequency of a sinewave,
but the response time is to slow, so evertime a state change takes place (button released/pressed) i want to interrupt the main program and set a new tuning word to look up in the dds table.
when i put the datapin on pin 3 an write

attachInterrupt(1, doPiano, CHANGE); // pin 3

then the function doPiano is called continuos, without pressing or releasing any button.
any suggestions?
i would appreciate.

greetings
peter

Korman

With the hardware you mention, no keyboard interrupts. You'll have to poll the keyboard by continuously cycling through the shift registers.

Korman

Graynomad

#2
Sep 29, 2010, 02:46 am Last Edit: Sep 29, 2010, 02:49 am by graynomad Reason: 1
Quote
but the response time is to slow
How slow, the SR read should happen in < a couple of uS I would think.

Quote
when i put the datapin on pin 3 an write

attachInterrupt(1, doPiano, CHANGE); // pin 3

This will interrupt on the first change of state coming out of the SR's data pin and probably all others. The interrupt(s) will occur part way through the shiftin function so your doPiano function will be called at the wrong time and with dodgy data.

Quote
then the function doPiano is called continuos, without pressing or releasing any button.
Can't explain that, unless the code is dicking with the data pin there should be no changes if no keys are pressed.

Also have a look at the MAX6818, that will give you an interrupt on any input change of state.
Rob Gray aka the GRAYnomad www.robgray.com

Grumpy_Mike

Quote
but the response time is to slow,

You haven't posted the code but there is probably a whacking big delay in the loop. Remove this for faster response.

Go Up