Paso 8: Más Software!
En modo 0, modo predeterminado, el Enigma no es más que una simple máquina de escribir con un recuadro que muestra su número de modelo.
Modo 1 permite al usuario seleccionar el 3 (de 8) rotores utilizará junto con que (2) Reflector que quiere utilizar.
En el modo 2, el usuario puede seleccionar la posición interna de cada Rotor.
Modo 3 se utiliza para especificar la posición inicial (externa) de cada Rotor.
En el modo 4, un usuario puede ingresar hasta 10 pares de intercambiados de letras.
Modo 5 es el modo de ejecución y en ese momento, el Enigma se cifrar o descifrar cualquier letra que se escribe en el teclado.
Aquí está el bosquejo completo que se ejecuta el Enigma entero:
/ * S & T GeoTronics Enigma código. Este escudo personalizado de Arduino Mega está programado para replicar
exactamente el comportamiento de una verdadera máquina Enigma M4 de alemán.
Utiliza 4 unidades de 16 segmentos, 5 LED, 26 instalación de lámparas como el teclado, los botones del teclado 26
Y 10 teclas de función. 115 luz diodos son charlie-plexed para reducir al mínimo la
cantidad de pines necesitada hasta 36 pulsadores 38 y todas las claves comparten un total de 4 pines.
Diseñado, montado y programado por Marc Tessier y James Sanderson 20/09/13
*/
Definir las variables
sin firmar largo tiempo = millis();
otime larga sin signo = tiempo;
int inpin [4] = {A0, A1, A2, A3};
inval int [4] = {0, 0, 0, 0};
keyval int = 100;
windex booleano = 0;
Boolean windex1 = 0;
Boolean windex2 = 0;
int lampval = 100;
int procesval = 0;
int procesvala = 0;
int modo = 0;
mtime largo sin firmar;
mdex int = 0;
Definir cada personaje Nixie
dig1 int = 37;
dig2 int = 37;
dig3 int = 37;
dig4 int = 37;
int datos [36] = {36,36,36,36,18,39,19,36,6,4,14,19,17,14,13,8,2,18,36,4,13,8,6,12,0,36,12,0,17,10,36,30,36,36,36,36};
Definir los pines de 16 segmentos como 2 matrices
segmento de int [17] = {24,22,25,31,38,36,32,30,28,26,23,27,33,35,34,29,37}; matriz de cátodo
ánodo de int [4] = {39,41,43,45}; Annode matriz commin annode
Definir las 26 lámparas como un Array 2D
int lamparray [26] [2] = {{12,10} {13,5}, {13,7}, {12,8}, {11,8}, {12,7,}, {12,6}, {12,5}, {11,3}, {12,4},
{12.3} {13,2}, {13,3}, {13,4}, {11,2}, {13.10}, {11,10}, {11,7}, {12,9}, {11,6},
{11,4} {13,6}, {11.9}, {13,8}, {13,9}, {11,5}};
Definir los 12 pines de la lámpara para la inicialización
int lamppin [12] = {2,3,4,5,6,7,8,9,10,11,12,13}; cátodo de 2 a 10, annode común de 11 a 13
Definir los segmentos de cada LTP587P: A, B, C, D, E, F, G, H, K, M, N, P, R, S, T, U, dp
Boolean segmentvals [40] [17] = {{0,0,0,0,1,1,0,0,1,1,1,0,1,1,1,0,1}, / / = 0
{0,0,0,0,0,0,1,1,1,0,1,0,1,0,1,1,1}, / / = B 1
{0,0,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1}, / / = C 2
{0,0,0,0,0,0,1,1,1,0,1,1,1,0,1,1,1}, / / = D 3
{0,0,1,1,0,0,0,0,1,1,1,0,1,1,1,0,1}, / / = E 4
{0,0,1,1,1,1,0,0,1,1,1,0,1,1,1,0,1}, / / = F 5
{0,0,1,0,0,0,0,0,1,1,1,0,1,1,1,1,1}, / / = G 6
{1,1,0,0,1,1,0,0,1,1,1,0,1,1,1,0,1}, / / = H 7
{0,0,1,1,0,0,1,1,1,0,1,1,1,0,1,1,1}, / / = I 8
{1,1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1}, / / = J 9
{1,1,1,1,1,1,0,0,1,1,0,1,0,1,1,0,1}, / / = K 10
{1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1}, / / = L 11
{1,1,0,0,1,1,0,0,0,1,0,1,1,1,1,1,1}, / / = M 12
{1,1,0,0,1,1,0,0,0,1,1,1,0,1,1,1,1}, / / = N 13
{0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1}, / / = O 14
{0,0,0,1,1,1,0,0,1,1,1,0,1,1,1,0,1}, / / = P 15
{0,0,0,0,0,0,0,0,1,1,1,1,0,1,1,1,1}, / / = Q 16
{0,0,0,1,1,1,0,0,1,1,1,0,0,1,1,0,1}, / / = R 17
{0,0,1,0,0,0,1,0,1,1,1,0,1,1,1,0,1}, / / = S 18
{0,0,1,1,1,1,1,1,1,0,1,1,1,0,1,1,1}, / / = T 19
{1,1,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1}, / / = U 20
{1,1,1,1,1,1,0,0,1,1,0,1,1,1,0,1,1}, / / = V 21
{1,1,0,0,1,1,0,0,1,1,1,1,0,1,0,1,1}, / / = W 22
{1,1,1,1,1,1,1,1,0,1,0,1,0,1,0,1,1}, / / = X 23
{1,1,1,1,1,1,1,1,0,1,0,1,1,0,1,1,1}, / / = Y 24
{0,0,1,1,0,0,1,1,1,1,0,1,1,1,0,1,1}, / / = Z 25
{0,0,0,0,0,0,0,0,1,1,0,1,1,1,0,1,1}, / / = 0 26
{1,1,0,0,1,1,1,1,1,1,0,1,1,1,1,1,1}, / / = 1 27
{0,0,0,1,0,0,0,1,1,1,1,0,1,1,1,0,1}, / / = 2 28
{0,0,0,0,0,0,1,1,1,1,1,0,1,1,1,1,1}, / / = 3 29
{1,1,0,0,1,1,1,0,1,1,1,0,1,1,1,0,1}, / / = 4 30
{0,0,1,0,0,0,1,0,1,1,1,0,1,1,1,0,1}, / / = 5 31
{0,0,1,0,0,0,0,0,1,1,1,0,1,1,1,0,1}, / / = 6 32
{0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1}, / / = 7 33
{0,0,0,0,0,0,0,0,1,1,1,0,1,1,1,0,1}, / / = 8 34
{0,0,0,0,0,0,1,0,1,1,1,0,1,1,1,0,1}, / / = 9 35
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, / / = espacio 36
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, / / = 37 encendido completo
{1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1}, / / = SS 38
{0,1,1,1,0,0,0,1,0,0,1,1,0,1,1,0,1}}; = & 39
LTP587P segmentos: A, B, C, D, E, F, G, H, K, M, N, P, R, S, T, U, dp
Definir los 5 LEDs de modo
int led1 = 40;
int led2 = 42;
led3 int = 44;
led4 int = 46;
led5 int = 48;
4,10,12, 5.11, 6, 3,16,21,25,13,19,14,22,24, 7,23,20,18,15, 0, 8, 1,17, 2, 9
Definir los valores del rotor A B C D E F G H I J K L M N O P Q
Static const int rotorvals [12] [78] = {{4,10,12, 5.11, 6, 3,16,21,25,13,19,14,22,24, 7,123,20,18,15, 0, 8, 1,17, 2, 9,
4,10,12, 5.11, 6, 3,16,21,25,13,19,14,22,24, 7,123,20,18,15, 0, 8, 1,17, 2, 9,
4,10,12, 5.11, 6, 3,16,21,25,13,19,14,22,24, 7,123,20,18,15, 0, 8, 1,17, 2, 9}, / / 1 de la rueda
{0, 9, 3,10,118, 8,17,20,23, 1.11, 7,22,19,12, 2,16, 6,25,13,15,24, 5,21,14, 4,
0, 9, 3,10,118, 8,17,20,23, 1.11, 7,22,19,12, 2,16, 6,25,13,15,24, 5,21,14, 4,
0, 9, 3,10,118, 8,17,20,23, 1.11, 7,22,19,12, 2,16, 6,25,13,15,24, 5,21,14, 4}, / / 2 de la rueda
{1, 3, 5, 7, 9,11, 2,15,17,19,23,21,25,13,24, 4, 8,22, 6, 0,10,112,20,18,16,14,
1, 3, 5, 7, 9,11, 2,15,17,19,23,21,25,13,24, 4, 8,22, 6, 0,10,112,20,18,16,14,
1, 3, 5, 7, 9,11, 2,15,17,19,23,21,25,13,24, 4, 8,22, 6, 0,10,112,20,18,16,14}, / / 3 de la rueda
{4,18,14,21,15,25, 9, 0,24,116,20, 8,17, 7,23,11,13, 5,19, 6,10, 3, 2,12,22, 1,
4,18,14,21,15,25 9, 0,24,116,20, 8,17, 7,23,11,13, 5,19, 6,10, 3, 2,12,22, 1,
4,18,14,21,15,25 9, 0,24,116,20, 8,17, 7,23,11,13, 5,19, 6,10, 3, 2,12,22, 1}, / / rueda 4
{21,25, 1,17, 6, 8,19,24,20,15,18, 3,13, 7,11,23, 0,22,12, 9,16,14, 5, 4, 2.110,
21,25, 1,17, 6, 8,19,24,20,15,18, 3,13, 7,11,23, 0,22,12, 9,16,14, 5, 4, 2.110,
21,25, 1,17, 6, 8,19,24,20,15,18, 3,13, 7,11,23, 0,22,12, 9,16,14, 5, 4, 2.110}, / / 5 de la rueda
{9,15, 6,21,14,20,12, 5,24,16, 1, 4.113, 7,25,17, 3,10, 0,18,23,11, 8, 2,19,122,
9,15, 6,21,14,20,12, 5,24,16, 1, 4.113, 7,25,17, 3,10, 0,18,23,11, 8, 2,19,122,
9,15, 6,21,14,20,12, 5,24,16, 1, 4.113, 7,25,17, 3,10, 0,18,23,11, 8, 2,19,122}, / / 6 de la rueda
{13,25 9, 7, 6,17, 2,23,12,24,18,22,101,14,20, 5, 0, 8,21,11,15, 4,10,16, 3.119,
13,25 9, 7, 6,17, 2,23,12,24,18,22,101,14,20, 5, 0, 8,21,11,15, 4,10,16, 3.119,
13,25 9, 7, 6,17, 2,23,12,24,18,22,101,14,20, 5, 0, 8,21,11,15, 4,10,16, 3.119}, / / 7 de la rueda
{5.10.16 7,19,11,23,14, 2, 1, 9,18,115, 3,25,17, 0,12, 4,22,13, 8,20,24, 6.121,
5.10.16 7,19,11,23,14, 2, 1, 9,18,115, 3,25,17, 0,12, 4,22,13, 8,20,24, 6.121,
5.10.16 7,19,11,23,14, 2, 1, 9,18,115, 3,25,17, 0,12, 4,22,13, 8,20,24, 6.121}, / / rueda 8
{11,4,24,9,21,2,13,8,23,22,15,1,16,12,3,17,19,0,10,25,6,5,20,7,14,18,
11,4,24,9,21,2,13,8,23,22,15,1,16,12,3,17,19,0,10,25,6,5,20,7,14,18,
11,4,24,9,21,2,13,8,23,22,15,1,16,12,3,17,19,0,10,25,6,5,20,7,14,18}, / / beta
{5,18,14,10,0,13,20,4,17,7,12,1,19,8,24,2,22,11,16,15,25,23,21,6,9,3,
5,18,14,10,0,13,20,4,17,7,12,1,19,8,24,2,22,11,16,15,25,23,21,6,9,3,
5,18,14,10,0,13,20,4,17,7,12,1,19,8,24,2,22,11,16,15,25,23,21,6,9,3}, / / gamma
{4,13,10,16,0,20,24,22,9,8,2,14,15,1,11,12,3,23,25,21,5,19,7,17,6,18,
4,13,10,16,0,20,24,22,9,8,2,14,15,1,11,12,3,23,25,21,5,19,7,17,6,18,
4,13,10,16,0,20,24,22,9,8,2,14,15,1,11,12,3,23,25,21,5,19,7,17,6,18}, / / = UKW-B
{17,3,14,1,9,13,19,10,21,4,7,12,11,5,2,22,25,0,23,6,24,8,15,18,20,16,
17,3,14,1,9,13,19,10,21,4,7,12,11,5,2,22,25,0,23,6,24,8,15,18,20,16,
17,3,14,1,9,13,19,10,21,4,7,12,11,5,2,22,25,0,23,6,24,8,15,18,20,16} / / = UKW-C
};
Static const int rotorvali [10] [78] = {{20,22,24, 6, 0, 3, 5,15,21,25, 1, 4, 2,10,12,19, 7,23,18,11,17, 8,13,16,14, 9,
20,22,24, 6, 0, 3, 5,15,21,25, 1, 4, 2,10,12,19, 7,23,18,11,17, 8,13,16,14, 9,
20,22,24, 6, 0, 3, 5,15,21,25, 1, 4, 2,10,12,19, 7,23,18,11,17, 8,13,16,14, 9}, //wheel 1 i
//
{0, 9,15, 2,25,22,17,11, 5, 1, 3,10,14,19,24,20,16, 6, 4,13, 7,23,12, 8,21,18,
0, 9,15, 2,25,22,17,11, 5, 1, 3,10,14,19,24,20,16, 6, 4,13, 7,23,12, 8,21,18,
0, 9,15, 2,25,22,17,11, 5, 1, 3,10,14,19,24,20,16, 6, 4,13, 7,23,12, 8,21,18}, //wheel 2
{19, 0, 6, 1,15, 2,18, 3,16, 4,20, 5,21,13,25, 7,24, 8,23, 9,22,11,17,10,14,12,
19, 0, 6, 1,15, 2,18, 3,16, 4,20, 5,21,13,25, 7,24, 8,23, 9,22,11,17,10,14,12,
19, 0, 6, 1,15, 2,18, 3,16, 4,20, 5,21,13,25, 7,24, 8,23, 9,22,11,17,10,14,12}, //wheel 3 i
{7,25,22,21, 0,17,19,13,11, 6,20,15,23,16, 2, 4, 9,12, 1,18,10, 3,24,14, 8, 5,
7,25,22,21, 0,17,19,13,11, 6,20,15,23,16, 2, 4, 9,12, 1,18,10, 3,24,14, 8, 5,
7,25,22,21, 0,17,19,13,11, 6,20,15,23,16, 2, 4, 9,12, 1,18,10, 3,24,14, 8, 5}, //wheel 4 i
{16, 2,24,11,23,22, 4,13, 5,19,25,14,18,12,21, 9,20, 3,10, 6, 8, 0,17,15, 7, 1,
16, 2,24,11,23,22, 4,13, 5,19,25,14,18,12,21, 9,20, 3,10, 6, 8, 0,17,15, 7, 1,
16, 2,24,11,23,22, 4,13, 5,19,25,14,18,12,21, 9,20, 3,10, 6, 8, 0,17,15, 7, 1}, //wheel 5 i
{18,10,23,16,11, 7, 2,13,22, 0,17,21,06,12, 4, 1, 9,15,19,24, 5, 3, 25,20, 8,14,
18,10,23,16,11 7, 2,13,22, 0,17,21,06,12, 4, 1, 9,15,19,24, 5, 3, 25,20, 8,14,
18,10,23,16,11, 7, 2,13,22, 0,17,21,06,12, 4, 1, 9,15,19,24, 5, 3, 25,20, 8,14}, //wheel 6
{16,12,6,24,21,15,4,3,17,2,22,19,8,0,13,20,23,5,10,25,14,18,11,7,9,1,
16,12,6,24,21,15,4,3,17,2,22,19,8,0,13,20,23,5,10,25,14,18,11,7,9,1,
16,12,6,24,21,15,4,3,17,2,22,19,8,0,13,20,23,5,10,25,14,18,11,7,9,1}, //wheel 7 i
{16,9,8,13,18,0,24,3,21,10,1,5,17,20,7,12,2,15,11,4,22,25,19,6,23,14,
16,9,8,13,18,0,24,3,21,10,1,5,17,20,7,12,2,15,11,4,22,25,19,6,23,14,
16,9,8,13,18,0,24,3,21,10,1,5,17,20,7,12,2,15,11,4,22,25,19,6,23,14}, //wheel 8 i
{17,11,5,14,1,21,20,23,7,3,18,0,13,6,24,10,12,15,25,16,22,4,9,8,2,19,
17,11,5,14,1,21,20,23,7,3,18,0,13,6,24,10,12,15,25,16,22,4,9,8,2,19,
17,11,5,14,1,21,20,23,7,3,18,0,13,6,24,10,12,15,25,16,22,4,9,8,2,19}, //Beta
{4,11,15,25,7,0,23,9,13,24,3,17,10,5,2,19,18,8,1,12,6,22,16,21,14,20,
4,11,15,25,7,0,23,9,13,24,3,17,10,5,2,19,18,8,1,12,6,22,16,21,14,20,
4,11,15,25,7,0,23,9,13,24,3,17,10,5,2,19,18,8,1,12,6,22,16,21,14,20}}; Gamma
Definir un Array 2D para mantener la ubicación de la rueda y posiciones
rueda int [3] [3] = {{26,0,0}, {26,0,0}, {26,0,0}};
int reflejar [2] = {1,0};
Definir la matriz de valores plugbord 25 x2 posición tiene 0 utilice la posición 1 tiene valor int plugu mantiene el número total de tapones usados (máximo 10)
int plugval [2] [26] = {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25}};
int pluguse = 0; int paindex = 0; int pbindex = 1;
void setup() {}
Inicialice los 38 pines del LED como salida
para (int index = 0; índice < = 11; índice ++) {}
pinMode (lamppin [index], salida);
digitalWrite(lamppin[index],1);
}
para (int index = 0; índice < = 3; Índice ++) {}
pinMode (ánodo [índice], salida);
digitalWrite (ánodo [índice], 1);
}
para (int index = 0; índice < = 16; índice ++) {}
pinMode (segmento [índice], salida);
digitalWrite (segmento [índice], 1);
}
pinMode(led1,OUTPUT);
pinMode(led2,OUTPUT);
pinMode(led3,OUTPUT);
pinMode(led4,OUTPUT);
pinMode(led5,OUTPUT);
Serial.Begin(9600);
Inicializar los 4 pernos de pusbutton como entrada
para (int index = 0; índice < = 3; Índice ++) {}
pinMode (inpin [índice], entrada);
}
}
void loop() {}
Debounce teclado y prueba de nuevo presionada
tiempo = millis();
Si (tiempo > otime + 500) {keyval = readkbde();}
Si ((keyval == 45) & & (windex == 1)) {modeselect();}
La operación de la máquina Enigma entera gira alrededor de la cual el modo de funcionamiento es actual
if(Mode == 0) {mode0();}
otra cosa if(mode == 1) {mode1();}
otra cosa if(mode == 2) {mode2();}
otra cosa if(mode == 3) {mode3();}
otra cosa if(mode == 4) {mode4();}
otra cosa if(mode == 5) {mode5();}
Else {}
Serial.println(keyval); para debuging imprime valor de teclado monitor serial / / para ejecutar o del
}
Esta función se encarga de averiguar qué tecla ha sido presionada y devuelve un entero único
int readkbde() {}
kval int = 100;
para (int index = 0; índice < = 3; Índice ++) {inval [índice] = analogRead(inpin[index]); } //Reads analógico de entrada valores
Si ((inval [0] > 925) & & (inval [1] > 828) & & (inval [2] > 730) & & (inval [3] > 828)) {kval = 100;} / / no pulse ninguna tecla
else if ((inval [0] < 924) & & (inval [0] > 915)) {kval = 49;} //up flecha 4
else if ((inval [0] < 914) & & (inval [0] > 903)) {kval = 48;} //up flecha 3
else if ((inval [0] < 902) & & (inval [0] > 887)) {kval = 47;} //up flecha 2
else if ((inval [0] < 886) & & (inval [0] > 865)) {kval = 46;} //up flecha 1
else if ((inval [0] < 864) & & (inval [0] > 836)) {kval = 45;} //mode
else if ((inval [0] < 834) & & (inval [0] > 793)) {kval = 44;} //enter
else if ((inval [0] < 792) & & (inval [0] > 724)) {kval = 43;}
else if ((inval [0] < 723) & & (594 > inval [0])) {kval = 42;}
else if ((inval [0] < 593) & & (inval [0] > 260)) {kval = 41;}
else if (inval [0] < 259) {kval = 40;}
else if ((inval [1] < 827) & & (inval [1] > 807)) {kval = 14;}
else if ((inval [1] < 806) & & (inval [1] > 781)) {kval = 8;}
else if ((inval [1] < 780) & & (inval [1] > 749)) {kval = 20;}
else if ((inval [1] < 748) & & (inval [1] > 706)) {kval = 25;}
else if ((inval [1] < 705) & & (inval [1] > 647)) {kval = 19;}
else if ((inval [1] < 646) & & (inval [1] > 555)) {kval = 17;}
else if ((inval [1] < 554) & & (inval [1] > 418)) {kval = 4;}
else if ((inval [1] < 417) & & (169 > inval [1])) {kval = 22;}
else if (inval [1] < 168) {kval = 16;}
else if ((inval [2] < 729) & & (inval [2] > 699)) {kval = 10;}
else if ((inval [2] < 698) & & (inval [2] > 660)) {kval = 9;}
else if ((inval [2] < 659) & & (inval [2] > 611)) {kval = 7;}
else if ((inval [2] < 610) & & (inval [2] > 547)) {kval = 6;}
else if ((inval [2] < 546) & & (inval [2] > 455)) {kval = 5;}
else if ((inval [2] < 454) & & (inval [2] > 331)) {kval = 3;}
else if ((inval [2] < 330) & & (inval [2] > 127)) {kval = 18;}
else if (inval [2] < 126) {kval = 0;}
else if ((inval [3] < 827) & & (inval [3] > 807)) {kval = 11;}
else if ((inval [3] < 806) & & (inval [3] > 781)) {kval = 12;}
else if ((inval [3] < 780) & & (inval [3] > 749)) {kval = 13;}
else if ((inval [3] < 748) & & (inval [3] > 706)) {kval = 1;}
else if ((inval [3] < 705) & & (inval [3] > 647)) {kval = 21;}
else if ((inval [3] < 646) & & (inval [3] > 555)) {kval = 2;}
else if ((inval [3] < 554) & & (inval [3] > 418)) {kval = 23;}
else if ((inval [3] < 417) & & (169 > inval [3])) {kval = 24;}
else if (inval [3] < 169) {kval = 15;}
Else {kval = 100;}
if(KVAL < 99) {otime = millis();} Contador de tiempo de debounce clave comienza
Si ((kval > = 0) & & (kval < = 99)) {windex = 1;} Windex mostrando verdadero (1) indica el retorno de un movimiento clave fresco
volver kval;
}
Función para cambiar el modo de funcionamiento
void modeselect() {}
modo ++;
Si (modo > = 6) {mode = 0;}
Windex = 0;
}
Por defecto: Enigma es una máquina de escribir
void mode0() {}
Si ((keyval > = 0) & & (keyval < = 25)) {lampval = keyval;}
lampita();
Marquee();
lampitb();
}
Seleccione los rotores y el Reflector
void mode1() {}
int index;
digitalWrite (LED 1, HIGH);
if(Windex == 1) {si ((keyval == 43) || (keyval == 46)) {reflejar [0] ++; si (reflejar [0] > 2) {reflejar [0] = 1;} Windex = 0 ;}}
if(Windex == 1) {if(keyval == 47) {para (índice =; (índice de rueda [2] [0] == wheel[1][0]) || (índice == wheel[0][0]) || (índice == wheel[2][0]);
Índice ++) {if(index > 33) {índice = 26;}} [2] [0] de la rueda = índice; Windex = 0 ;}}
if(Windex == 1) {if(keyval == 48) {para (índice =; (índice de rueda [1] [0] == wheel[2][0]) || (índice == wheel[0][0]) || (índice == wheel[1][0]);
Índice ++) {if(index > 33) {índice = 26;}} rueda [1] [0] = índice; Windex = 0 ;}}
if(Windex == 1) {if(keyval == 49) {para (índice =; (índice de rueda [0] [0] == wheel[2][0]) || (índice == wheel[1][0]) || (índice == wheel[0][0]);
Índice ++) {if(index > 33) {índice = 26;}} rueda [0] [0] = índice; Windex = 0 ;}}
if(Windex == 1) {if(keyval == 42) {para (índice =; (índice de rueda [2] [0] == wheel[1][0]) || (índice == wheel[0][0]) || (índice == wheel[2][0]);
Índice--) {if(index < 28) {índice = 35;}} [2] [0] de la rueda = índice; Windex = 0 ;}}
if(Windex == 1) {if(keyval == 41) {para (índice =; (índice de rueda [1] [0] == wheel[2][0]) || (índice == wheel[0][0]) || (índice == wheel[1][0]);
Índice--) {if(index < 28) {índice = 35;}} rueda [1] [0] = índice; Windex = 0 ;}}
if(Windex == 1) {if(keyval == 40) {para (índice =; (índice de rueda [0] [0] == wheel[2][0]) || (índice == wheel[1][0]) || (índice == wheel[0][0]);
Índice--) {if(index < 28) {índice = 35;}} rueda [0] [0] = índice; Windex = 0 ;}}
dig2 = rueda [2] [0]; dig3 = rueda [1] [0]; dig4 = rueda [0] [0]; dig1 = reflejar [0];
nixisend();
dig1 = 37; dig2 = 37; dig3 = 37; dig4 = 37;
digitalWrite (LED 1, bajo);
}
Posición de la configuración interna de cada Rotor
void mode2() {}
digitalWrite (led2, HIGH);
if(Windex == 1) {}
if(keyval == 47) {rueda [2] [1] ++; si ([2] [1] la rueda > 25) {[2] [1] de la rueda = 0 ;}}
if(keyval == 48) {rueda [1] [1] ++; si (rueda [1] [1] > 25) {rueda [1] [1] = 0 ;}}
if(keyval == 49) {rueda [0] [1] ++; si (rueda [0] [1] > 25) {rueda [0] [1] = 0 ;}}
if(keyval == 42) {[2] [1]--la rueda; si (rueda [2] [1] < 0) {[2] [1] de la rueda = 25 ;}}
if(keyval == 41) {rueda [1] [1]--; si (rueda [1] [1] < 0) {rueda [1] [1] = 25 ;}}
if(keyval == 40) {rueda [0] [1]--; si (rueda [0] [1] < 0) {[0] [1] de la rueda = 25 ;}}
Windex = 0; }
dig2 = rueda [2] [1]; dig3 = rueda [1] [1]; dig4 = rueda [0] [1]; dig1 = 0;
nixisend();
dig1 = 37; dig2 = 37; dig3 = 37; dig4 = 37;
digitalWrite (led2, LOW);
}
Posición el carácter de comienzo de cada rueda
void mode3() {}
digitalWrite (LED 3, alto);
if(Windex == 1) {}
if(keyval == 46) {reflejar [1] ++; si (reflejar [1] > 25) {reflejar [1] = 0 ;}}
if(keyval == 47) {rueda [2] [2] ++; si ([2] [2] la rueda > 25) {[2] [2] de la rueda = 0 ;}}
if(keyval == 48) {rueda [1] [2] ++; si (rueda [1] [2] > 25) {rueda [1] [2] = 0 ;}}
if(keyval == 49) {rueda [0] [2] ++; si (rueda [0] [2] > 25) {rueda [0] [2] = 0 ;}}
if(keyval == 43) {reflejar [1]--; si (reflejar [1] < 0) {reflejar [1] = 25 ;}}
if(keyval == 42) {[2] [2], la rueda; si (rueda [2] [2] < 0) {[2] [2] de la rueda = 25 ;}}
if(keyval == 41) {rueda [1] [2]--; si (rueda [1] [2] < 0) {rueda [1] [2] = 25 ;}}
if(keyval == 40) {rueda [0] [2]--; si (rueda [0] [2] < 0) {[0] [2] de la rueda = 25 ;}}
Windex = 0; }
dig2 = rueda [2] [2]; dig3 = rueda [1] [2]; dig4 = rueda [0] [2]; dig1 = reflejar [1];
nixisend();
dig1 = 37; dig2 = 37; dig3 = 37; dig4 = 37;
digitalWrite (LED 3, bajo);
}
Definir los pares Plugboard
void mode4() {}
Índice de int = 0;
digitalWrite (led4, HIGH);
Si (pluguse < = 9) {}
Si (plugval [0] [paindex] == 1) {para (índice = paindex;(index == paindex) || (índice == pbindex) || (plugval [0] [índice] == 1); Índice ++) {if(index > 24) {index = -1 ;}} paindex = índice;}
Si (plugval [0] [pbindex] == 1) {para (índice = pbindex;(index == pbindex) || (índice == paindex) || (plugval [0] [índice] == 1); Índice ++) {if(index > 24) {index = -1 ;}} pbindex = índice;}
if(Windex == 1) {}
if(keyval == 46) {para (índice = paindex;(index == paindex) || (índice == pbindex) || (plugval [0] [índice] == 1); Índice ++) {if(index > 24) {index = -1 ;}} paindex = índice; Windex = 0; }
if(keyval == 43) {para (índice = paindex;(index == paindex) || (índice == pbindex) || (plugval [0] [índice] == 1); Índice--) {if(index < 1) {índice = 26 ;}} paindex = índice; Windex = 0; }
if(keyval == 49) {para (índice = pbindex;(index == pbindex) || (índice == paindex) || (plugval [0] [índice] == 1); Índice ++) {if(index > 24) {index = -1 ;}} pbindex = índice; Windex = 0; }
if(keyval == 40) {para (índice = pbindex;(index == pbindex) || (índice == paindex) || (plugval [0] [índice] == 1); Índice--) {if(index < 1) {índice = 26 ;}} pbindex = índice; Windex = 0; }
if(keyval == 44) {plugval [0] [paindex] = 1; plugval [1] [paindex] = pbindex; plugval [0] [pbindex] = 1; plugval [1] [pbindex] = paindex; windex = 0; pluguse ++;}
}
dig2 = 19; dig3 = 14; dig4 = pbindex; dig1 = paindex;
nixisend();
dig1 = 37; dig2 = 37; dig3 = 37; dig4 = 37;
}
Else {done();}
digitalWrite (led4, LOW);
}
Este es el modo de operación Normal para cifrar/descifrar
void mode5() {}
int pv = 0;
digitalWrite (led5, HIGH);
Si ((keyval > = 0) & & (keyval < = 25)) {if(windex == 1) {procesvala = keyval; indexwheels() ;}}
Windex = 0;
procesval = procesvala;
procesval = plugval [1] [procesval];
Serial.Print (procesval); Serial.Print("");
PV = (procesval + (rueda [0] [2] - wheel[0][1]));
if(PV < 0) {pv = pv + 26;}
procesval = rotorvals [rueda [0] [0] -27] [pv];
Si (procesval > = 100) {procesval = procesval - 100;}
procesval = (procesval - (rueda [0] [2] - wheel[0][1]));
if(procesval < 0) {procesval = procesval + 26;} if(procesval > 25) {procesval = procesval - 26;}
Serial.Print (procesval); Serial.Print("");
PV = (procesval + (rueda [1] [2] - wheel[1][1]));
if(PV < 0) {pv = pv + 26;}
procesval = rotorvals [rueda [1] [0] -27] [pv];
Si (procesval > = 100) {procesval = procesval - 100;}
procesval = (procesval - (rueda [1] [2] - wheel[1][1]));
if(procesval < 0) {procesval = procesval + 26;} if(procesval > 25) {procesval = procesval - 26;}
Serial.Print (procesval); Serial.Print("");
PV = (procesval + ([2] [2] - de la rueda wheel[2][1]));
if(PV < 0) {pv = pv + 26;}
procesval = rotorvals [[2] [0] de la rueda -27] [pv];
Si (procesval > = 100) {procesval = procesval - 100;}
procesval = (procesval - (rueda [2] [2] - wheel[2][1]));
if(procesval < 0) {procesval = procesval + 26;} if(procesval > 25) {procesval = procesval - 26;}
Serial.Print (procesval); Serial.Print("");
PV = (procesval);
procesval = rotorvals [reflejar [0] + 7] [pv];
Si (procesval > = 100) {procesval = procesval - 100;}
if(procesval < 0) {procesval = procesval + 26;} if(procesval > 25) {procesval = procesval - 26;}
Serial.Print (procesval); Serial.Print("");
procesval = rotorvals [reflejar [0] + 9] [procesval];
Serial.Print (procesval); Serial.Print("");
PV = (procesval + 26);
procesval = rotorvali [reflejar [0] + 7] [pv];
Si (procesval > = 100) {procesval = procesval - 100;}
if(procesval < 0) {procesval = procesval + 26;} if(procesval > 25) {procesval = procesval - 26;}
Serial.Print (procesval); Serial.Print("");
PV = (procesval + ([2] [2] - de la rueda wheel[2][1]));
if(PV < 0) {pv = pv + 26;}
procesval = rotorvali [[2] [0] de la rueda -27] [pv];
Si (procesval > = 100) {procesval = procesval - 100;}
procesval = (procesval - (rueda [2] [2] - wheel[2][1]));
if(procesval < 0) {procesval = procesval + 26;} if(procesval > 25) {procesval = procesval - 26;}
Serial.Print (procesval); Serial.Print("");
PV = (procesval + (rueda [1] [2] - wheel[1][1]));
if(PV < 0) {pv = pv + 26;}
procesval = rotorvali [rueda [1] [0] -27] [pv];
Si (procesval > = 100) {procesval = procesval - 100;}
procesval = (procesval - (rueda [1] [2] - wheel[1][1]));
if(procesval < 0) {procesval = procesval + 26;} if(procesval > 25) {procesval = procesval - 26;}
Serial.Print (procesval); Serial.Print("");
PV = (procesval + (rueda [0] [2] - wheel[0][1]));
if(PV < 0) {pv = pv + 26;}
procesval = rotorvali [rueda [0] [0] -27] [pv];
Si (procesval > = 100) {procesval = procesval - 100;}
procesval = (procesval - (rueda [0] [2] - wheel[0][1]));
if(procesval < 0) {procesval = procesval + 26;} if(procesval > 25) {procesval = procesval - 26;}
Serial.Print (procesval); Serial.Print("");
procesval = plugval [1] [procesval];
lampval = procesval;
Serial.println(lampval);
dig2 = rueda [2] [2]; dig3 = rueda [1] [2]; dig4 = rueda [0] [2]; dig1 = reflejar [1];
lampita();
nixisend();
lampitb();
dig1 = 37; dig2 = 37; dig3 = 37; dig4 = 37;
digitalWrite (led5, LOW);
}
Función de auxiliar a la luz de la tecla adecuada
void lampita() {}
digitalWrite(lamparray[lampval][0],0);
digitalWrite(lamparray[lampval][1],0);
}
void lampitb() {}
digitalWrite(lamparray[lampval][0],1);
digitalWrite(lamparray[lampval][1],1);
}
Función de ayuda para iluminar "Nixies"
void nixisend() {}
sixteenSegWrite (0, dig1);
sixteenSegWrite 1, dig2;
sixteenSegWrite 2, dig3;
sixteenSegWrite 3, dig4;
}
void marquee() {}
tiempo = millis();
Si (mtime < tiempo) {}
mtime = tiempo + 400;
MDEX ++;}
dig1 = datos [mdex];
dig2 = datos [mdex + 1];
dig3 = datos [mdex + 2];
dig4 = datos [mdex + 3];
Si (mdex > = 31) {mdex = 0;}
nixisend();
}
Función que convierte en realidad en cada uno de los 17 segmentos apropiados en cada "Nixie"
{} void sixteenSegWrite (int dígitos, int carácter)
digitalWrite(anode[digit],0);
para (int index = 0; índice < 17; Índice ++) {}
digitalWrite (segmento [índice], segmentvals[character][index]);
}
Delay(7);
para (int index = 0; índice < = 16; índice ++) {}
digitalWrite (segmento [índice], 1);
}
digitalWrite (ánodo [dígito], 1);
}
{} void done()
dig1 = 3; dig2 = 14; dig3 = 13; dig4 = 4;
nixisend();
dig1 = 37; dig2 = 37; dig3 = 37; dig4 = 37;
}
void indexwheels() {}
Serial.Print(rotorvals[wheel[0][0]-27][wheel[0][2]]);
Serial.Print(""); Serial.Print(wheel[0][0]-27); Serial.Print(""); Serial.println(wheel[0][2]);
Si (rotorvals [rueda [0] [0] -27] [rueda [0] [2]] > = 100) {windex1 = 1;}
rueda [0] [2] ++; Si (rueda [0] [2] > 25) {rueda [0] [2] = 0;}
Windex = 0;
if(windex1 == 1) {}
Si (rotorvals [rueda [1] [0] -27] [rueda [1] [2]] > = 100) {windex2 = 1;}
rueda [1] [2] ++; Si (rueda [1] [2] > 25) {rueda [1] [2] = 0 ;}}
windex1 = 0;
if(windex2 == 1) {}
ruedas [2] [2] ++; Si ([2] [2] la rueda > 25) {rueda [2] [2] = 0;}
windex2 = 0; }
}
IF hay suficiente interés, planeamos crear un PCB que se permitirá para facilitar tanto el montaje de esta maravillosa réplica de Enigma completamente funcional. Por favor visite http://www.stgeotronics.com para obtener información sobre disponibilidad, precios y para hacer su pedido o pre-ordenar ahora. Los esquemas de circuito se publican, por lo que el PCB ha entrado en su etapa de desarrollo. Pronto a ser probado.