OK, I Have had it up to you know where with the GRAY CODE!! When I have written this decoder in software, it takes a loop or two, It just eats CPU time. This is ok if you can use interrupts. But the Ardunio does not return the interrupt value to you directly. No, it uses what is called a SIDE-EFFECT! Incredibly, this means you have to look for the interrupt number. This is from the Arduino website itself: "ISRs are special kinds of functions that have some unique limitations most other functions do not have. An ISR cannot have any parameters, and they shouldn't return anything." This is not correct, in fact, the return type must be a VOID. So I have crawled back to my hardware days and came up with this: (diagram below). Now I can take the decoded BCD and apply it to an MCP23017. Now I have two choices waste a nibble (4-bits) which will handle 2 decoders or 4 decoders but I will have to do some bit shifting. - CAH Nov 2, 2K22
Part | Price | Count | Price |
---|---|---|---|
SN74LS00N | 0.12 | 3 | 0.36 |
SN74LS08N | 0.98 | 1 | 0.98 |
SN74LS148N | 2.05 | 2 | 4.10 |
TOTAL | 5.44 | ||
Prices are from Newark Electronics |
2 of 5 Gray Code | BCD | ||||||||
INPUTS | OUTPUTS | ||||||||
A | B | C | D | E | D | C | B | A | |
0 | X | X | 0 | 0 | 0 | 0 | |||
1 | X | X | 0 | 0 | 0 | 1 | |||
2 | X | X | 0 | 0 | 1 | 0 | |||
3 | X | X | 0 | 0 | 1 | 1 | |||
4 | X | X | 0 | 1 | 0 | 0 | |||
5 | X | X | 0 | 1 | 0 | 1 | |||
6 | X | X | 0 | 1 | 1 | 0 | |||
7 | X | X | 0 | 1 | 1 | 1 | |||
8 | 1 | 0 | 0 | 0 | |||||
9 | X | X | 1 | 0 | 0 | 1 |