My project simulates the “german railway” 3-rotor enigma machine. The message is limited to 16 characters. (LCD is 16X2).
When enter is pressed on the keyboard the transmissions starts.
Transmitter
To read the input message from the keyboard I used the USBHost library; For the LCD HD44780 I used the Liquidcrystal library. Since I didn’t have a 26 posintion commuter (for simulating the rotors positions) and not to waste 52 pins I used 3 potenziometers, one for each rotor, I transformed the analog value read from the analog input to 26 virtual digital states, one for each letter. With a lever I can switch between the rotor view and the message view.
Once encrypted the message is converted to morse code. The morse dot is 100ms, the line is three times the length of a dot, a pause between line and dot is 100ms and at the end of a word a pause of the duration of three dots. Using the Arduino pwm modulation I transmit a 1khz square wave.
Receiver
The hardware filters the 1khz wave from other noise and detects the 1khz light. One problem was the energy saver flourescent lamp I have in my room so I used a debouncer to prevent false positives and trimmed the minimum quantity of 1khz light the arduino needs to read a signal.
I converted series of dots and lines in letters and simulated the rotors shifts changing the indexs of the rotor tables arrays. At the end of all the substitutions the letter is displayed on the lcd.