Your LED cube ENGR 40M Chuan-Zheng Lee Stanford University 28 - - PowerPoint PPT Presentation
Your LED cube ENGR 40M Chuan-Zheng Lee Stanford University 28 - - PowerPoint PPT Presentation
Your LED cube ENGR 40M Chuan-Zheng Lee Stanford University 28 July 2017 Electrically its 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
Electrically it’s an array, but physically…
July 28, 2017 ENGR 40M Summer 2017 — C.Z. Lee, J. Plummer, R. Howe 2 E
How do we arrange these in a 4 × 4 × 4 cube?
…it’s a cube?
July 28, 2017 ENGR 40M Summer 2017 — C.Z. Lee, J. Plummer, R. Howe 3 E E
…it’s a cube?
July 28, 2017 ENGR 40M Summer 2017 — C.Z. Lee, J. Plummer, R. Howe 4
bottom second from bottom second from top top
E E
Decomposition
July 28, 2017 ENGR 40M Summer 2017 — C.Z. Lee, J. Plummer, R. Howe 5
loop() display() getLEDState() The main Arduino loop Does one pass through the LEDs (time-division multiplexing) Looks up the LED state associated with an anode/cathode pair
calls which calls
Mapping between 2-D and 3-D
July 28, 2017 ENGR 40M Summer 2017 — C.Z. Lee, J. Plummer, R. Howe 6
E E
y
Mapping between 2-D and 3-D
We want a function that maps from anode/cathode pairs 𝑏, 𝑑 (e.g. “ ”) to 3D coordinates 𝑦, 𝑧, 𝑨
July 28, 2017 ENGR 40M Summer 2017 — C.Z. Lee, J. Plummer, R. Howe 7
y
Mapping between 2-D and 3-D
Anodes Cathodes
July 28, 2017 ENGR 40M Summer 2017 — C.Z. Lee, J. Plummer, R. Howe 8
y y
Mapping between 2-D and 3-D
y
Operations we might consider using:
- * (multiplication)
- % (modulo division)
- / (integer division)
- & (bitwise and)
- | (bitwise or)
- ^ (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 𝑦, 𝑧, 𝑨
July 28, 2017 ENGR 40M Summer 2017 — C.Z. Lee, J. Plummer, R. Howe 11
y
Mapping between 2-D and 3-D
Anodes Cathodes
July 28, 2017 ENGR 40M Summer 2017 — C.Z. Lee, J. Plummer, R. Howe 12
y y
Making the mapping function easier
y y
July 28, 2017 ENGR 40M Summer 2017 — C.Z. Lee, J. Plummer, R. Howe 13
You can reorder the anodes/cathodes however you like. Would a different ordering make the relationship simpler?
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
July 28, 2017 ENGR 40M Summer 2017 — C.Z. Lee, J. Plummer, R. Howe 15