Go Down

Topic: Convert Decimal to Binary and write to pins. (Read 8 times) previous topic - next topic

retrolefty

#5
Mar 29, 2009, 10:36 pm Last Edit: Mar 29, 2009, 10:39 pm by retrolefty Reason: 1
Quote
I can explain this better if it's not clear.


That might be helpful.

Normally the strategy of using interrupt routines is to do as little as possible inside the interrupt routine, doing it inline and not calling any subroutine functions, just increment or decrement a global variable or flag variable that the main sketch can test or compare and take action on. The idea is to take up as few processor cycles as possible to lessen the risk of missing future interrupt signals while servicing a previous interrupt signal or effecting other waitinf interrupt functions. While a ISR routine is being service all other interrupts are disabled until the ISR routine completes.

In the case of interrupting encoder signals the minimum required task is to update (by incrementing or decrementing) a global 'step count' variable and a global direction flag variable inside the ISR routine and then return to the main sketch. Then the main sketch can act on these changed global variables as it loops through the main routine.

That make sense?

Lefty


1040ez

That does help, Lefty; I opted to just use the simple rotary code since interrupts weren't what I needed.

Alright, I think I have my code working, but I'm having an issue hooking up the final product. I can't figure out what pinouts to use. Here's what I have:

http://www.ladyada.net/images/pshield/miniproto_t.jpg

It's hooked up to a Diecimila USB, and I have the following pins specified:

0 and 1 - rotary encoder
2, 3, and 4 - buttons
5, 6, 7, 8 - 7-segment display
11 - motor (PWM)

If my understanding is correct, each of those numbers refers to the pins labeled "Digital I/O" on the board, so 0 and 1 are Digital I/O 0 and 1. Is this correct?


retrolefty

Quote
If my understanding is correct, each of those numbers refers to the pins labeled "Digital I/O" on the board, so 0 and 1 are Digital I/O 0 and 1. Is this correct?


That is correct. By the way generally people avoid using digital pins 0 & 1 as they are hardwired to the USB serial link used to upload new programs or send serial data to a PC application.

Lefty

Go Up