Reed switch array - false readings (programming not wiring)


hello everyone,

i quite new arduino , programming in general. first post have spent lot of time on forum looking answers kinds of problems , contributors of time there old post need. 1 day can contribute!

i have wired 8x4 reed switch matrix (it 8x8 alot of soldering!) using berger's chess matrix. matrix uses reed switch , diode on each position, diodes prevent 'ghosting' when more 1 reed switch signals. program scans 1 row @ time, same principal keyboard library. of wiring correct testfunction of program works fine.

the program searches change of state, checks see if reed switch has gone off or on , looks change of state. meant work chess board , serial print move such me1e2. 90% of time happens 10% of time 'invalid move'.

i appreciate if have @ program see if there obvious mistakes or if approaching wrong way. have tried , tried fix think think have been overambitious project , require of forum.

thanks,
dan

unfortunately code long have attached it.

that's hefty code there. take me more time i'm willing spend go through (sorry), point out jumps out - may or may not problem:

you have big globals in form of currentstate, previousstate , reading.
in pickfunction() can go halfway through i,j loop, writing these big globals go, , jump placefunction(). in function start new i,j loop , write again partially previously, partially modified, globals - , can again jump capturefunction(). in function start yet i,j loop , modify globals.
are each time return sub-function globals in suitable state?

without having thought thoroughly through, might have done single 2d array , used enum store state of each square, eg. empty, occupied, lifting (during debounce), lifted, etc.

in case, try printing more debug statements determine under conditions getting invalid move. maybe print out entire contents of each global when error occurs.


Arduino Forum > Using Arduino > Programming Questions > Reed switch array - false readings (programming not wiring)


arduino

Comments

Popular posts from this blog

Flip address is out of range arduino uno r3

Arduino Uno not uploading

Indesign and MathType fonts