Step 7The Code:Overview
The code also needs to handle the rotors moving. The right most rotor moves one spot every time a key is pushed. The middle rotor moves when the right most rotor hits a certain value (so it will turn 1/26 of the times the right one turns). The left rotor turns 1/26 of the times the center rotor turns. To do this I have an int that keeps track of the current position of the rotor and I add one to it when they need to turn. When they get to 26 I set them back to 0 (it went all the way around the rotor so we're starting again).
To swap out rotors I simply strncpy the rotor constants to the rotor in for the position.
You'll notice I used a lot of example code in my code to do things like play tones, get keypad values, and address the I2C LCD. I'm a big fan of libraries and example code.
enigma.pde8 KB| « Previous Step | Download PDFView All Steps | Next Step » |
![]() |
Add Comment
|














































