I just want to know from where he got this equations? (exact)
This:
Code: Select all
90 w=sq+1 # different numbering system
91 x =int((w-1)/3)+1 # anodes numbers starts 1
92 y = (2+w)%3 # cathodes number start 0thanks all!
Code: Select all
90 w=sq+1 # different numbering system
91 x =int((w-1)/3)+1 # anodes numbers starts 1
92 y = (2+w)%3 # cathodes number start 0Their code numbers the cells on the 3x3 board from 1 to 9 and those lines convert a cell number into X + Y coordinates to turn on/off a LED. They worked it out themselves as it is an implementation detail for their project and isn't anything complicated.9acca9 wrote: ↑Mon Sep 09, 2019 7:06 pmI just want to know from where he got this equations? (exact)
This:
Code: Select all
90 w=sq+1 # different numbering system 91 x =int((w-1)/3)+1 # anodes numbers starts 1 92 y = (2+w)%3 # cathodes number start 0
[pedant] It looks like x is 1 based, not 0. Hence, the comments in the code. Why x and y should have different bases is anyone's guess. [/pedant]
You, sir, are correct.davidcoton wrote: ↑Mon Sep 09, 2019 9:46 pm[pedant] It looks like x is 1 based, not 0. Hence, the comments in the code. Why x and y should have different bases is anyone's guess. [/pedant]
Code: Select all
x = (sq // 3) + 1
y = sq % 3