Your LED cube ENGR 40M Chuan-Zheng Lee Stanford University 28 July 2017
Electrically it’s an array, but physically… How do we arrange these in a 4 × 4 × 4 cube? E July 28, 2017 ENGR 40M Summer 2017 — C.Z. Lee, J. Plummer, R. Howe 2
…it’s a cube? E E July 28, 2017 ENGR 40M Summer 2017 — C.Z. Lee, J. Plummer, R. Howe 3
…it’s a cube? second bottom from bottom E E second top from top July 28, 2017 ENGR 40M Summer 2017 — C.Z. Lee, J. Plummer, R. Howe 4
Decomposition The main Arduino loop loop() calls Does one pass through the LEDs display() (time-division multiplexing) which calls Looks up the LED state associated with an getLEDState() anode/cathode pair July 28, 2017 ENGR 40M Summer 2017 — C.Z. Lee, J. Plummer, R. Howe 5
Mapping between 2-D and 3-D E E y July 28, 2017 ENGR 40M Summer 2017 — C.Z. Lee, J. Plummer, R. Howe 6
Mapping between 2-D and 3-D We want a function that maps from anode/cathode pairs 𝑏, 𝑑 (e.g. “ ”) to 3D coordinates 𝑦, 𝑧, 𝑨 y July 28, 2017 ENGR 40M Summer 2017 — C.Z. Lee, J. Plummer, R. Howe 7
Mapping between 2-D and 3-D Anodes Cathodes y y July 28, 2017 ENGR 40M Summer 2017 — C.Z. Lee, J. Plummer, R. Howe 8
Mapping between 2-D and 3-D Operations we might consider using: • * (multiplication) • % (modulo division) • / (integer division) • & (bitwise and) • | (bitwise or) y • ^ (bitwise xor) July 28, 2017 ENGR 40M Summer 2017 — C.Z. Lee, J. Plummer, R. Howe 9
What do bitwise operations do? • Bitwise operations apply to ea each bit it in the binary representation of a number in indi divid idually Examples (in binary): 00110101 | 01100011 == 01110111 00110101 & 01100011 == 00100001 00110101 00110101 | 01100011 & 01100011 01110111 00100001 July 28, 2017 ENGR 40M Summer 2017 — C.Z. Lee, J. Plummer, R. Howe 10
Mapping between 2-D and 3-D We want a function that maps from anode/cathode pairs 𝑏, 𝑑 (e.g. “ ”) to 3D coordinates 𝑦, 𝑧, 𝑨 y July 28, 2017 ENGR 40M Summer 2017 — C.Z. Lee, J. Plummer, R. Howe 11
Mapping between 2-D and 3-D Anodes Cathodes y y July 28, 2017 ENGR 40M Summer 2017 — C.Z. Lee, J. Plummer, R. Howe 12
Making the mapping function easier You can reorder the anodes/cathodes however you like. Would a different ordering make the relationship simpler? y y July 28, 2017 ENGR 40M Summer 2017 — C.Z. Lee, J. Plummer, R. Howe 13
Mapping between 2-D and 3-D y July 28, 2017 ENGR 40M Summer 2017 — C.Z. Lee, J. Plummer, R. Howe 14
Mapping between 2-D and 3-D y July 28, 2017 ENGR 40M Summer 2017 — C.Z. Lee, J. Plummer, R. Howe 15
Recommend
More recommend