Video:
Arduino code:
String inString = "";
int inChar;
char outChar;
int count;
void setup() {
Serial.begin(9600);
while (!Serial) {
;
}
Serial.println("Hello! Select encrypt or decrypt button!");
}
void loop(){
while (Serial.available() > 0) {
inString = Serial.read();
int inChar = inString.toInt();
if (inChar == 43){
count = 1;
}
if (inChar == 45){
count = 2;
}
if (count == 1){
inChar = inChar + 1;
outChar = inChar;
Serial.print((char)outChar);
}
if (count == 2){
inChar = inChar - 1;
outChar = inChar;
Serial.print((char)outChar);
}
}
delay(1000);
}
Visual Basic code
settigs: timer1 interval 100,
serialsPort1: rtsEnable true, dtrEnabe true
Code:
Imports System.IO.Ports
Imports System.Threading
Public Class Form1
Dim comPORT As String
Dim receivedData As String = ""
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Timer1.Enabled = False
comPORT = ""
For Each sp As String In My.Computer.Ports.SerialPortNames
ComboBox1.Items.Add(sp)
Next
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If (Button1.Text = "Start") Then
If (comPORT <> "") Then
SerialPort1.Close()
SerialPort1.PortName = comPORT
SerialPort1.BaudRate = 9600
SerialPort1.DataBits = 8
SerialPort1.Parity = Parity.None
SerialPort1.StopBits = StopBits.One
SerialPort1.Handshake = Handshake.None
SerialPort1.Encoding = System.Text.Encoding.Default 'very important!
SerialPort1.ReadTimeout = 10000
SerialPort1.Open()
Button1.Text = "Stop"
Timer1.Enabled = True
Button2.Enabled = True
Button3.Enabled = True
Button4.Enabled = True
Button5.Enabled = True
TextBox2.Enabled = True
Else
MsgBox("Select a COM port first")
End If
Else
SerialPort1.Close()
Button1.Text = "Start"
Timer1.Enabled = False
Button2.Enabled = False
Button3.Enabled = False
Button4.Enabled = False
Button5.Enabled = False
End If
End Sub
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
If (ComboBox1.SelectedItem <> "") Then
comPORT = ComboBox1.SelectedItem
End If
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
receivedData = ReceiveSerialData()
If (receivedData.LongCount > 0) Then
TextBox1.Text = receivedData
End If
End Sub
Function ReceiveSerialData() As String
Dim Incoming As String
Try
Incoming = SerialPort1.ReadExisting()
If Incoming Is Nothing Then
Return "nothing" & vbCrLf
Else
Return Incoming
End If
Catch ex As TimeoutException
Return "Error: Serial Port read timed out."
End Try
End Function
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
SerialPort1.Write("+")
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
SerialPort1.Write("-")
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
SerialPort1.Write(TextBox2.Text)
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
TextBox2.Text = Nothing
End Sub
End Class
Download this Enigma VB preject file:
https://drive.google.com/file/d/1AKSpDnQt0m0-v7WBmpes4OmMDYPetEgj/view?usp=sharing
Download this Enigma VB sotware:
https://drive.google.com/file/d/1QdRv6hOUGNwwzjSQMCPYgjYWCEqWQVBX/view?usp=sharing
------------