Rubiks Cube Solver Tester
Het hele programma is hier onder te downloaden bij "Download alles" dit is de complete documentatie die je nodig hebt al wil je het programma aanpassen. Als je er wat leuks mee gedaan hebt, of verbeteringen heb kun je dat gewoon in het contacten formulier zetten. Ik zal er dan zo spoedig mogelijk naar kijken. Als je alleen het programma wilt downloaden kun je de .exe ook downloaden. Dit is alleen de toepassing en kan niet aangepast worden.
Een programma om de Rubiks Cube Solver te eiken en te testen, Zie deze pagina voor de documentatie over de oplosser
Download Alles (Visual studio nodig!)
Download alleen het .exe bestand
Een programma om de Rubiks Cube Solver te eiken en te testen, Zie deze pagina voor de documentatie over de oplosser
Download Alles (Visual studio nodig!)
Download alleen het .exe bestand
De volledige code zoals in Visual Studio
' This code is written by Jelle Wie WWW.Jellewie.Weebly.Com
'
Imports System
Imports System.Threading
Imports System.IO.Ports
Imports System.ComponentModel
Public Class Serial_Data
Dim MSGBoxName As String
Dim MSG As String
Dim myPort As Array
Dim ArduinoAnswer As String
Dim ButtonSelected As String
Dim PrefUSB As String
'Put under this line your own strings
Dim LeftState As Integer
Dim FrontState As Integer
Dim RightState As Integer
Dim ClamFrontState As Integer
Delegate Sub SetTextCallback(ByVal [text] As String) 'Added to prevent threading errors during receiveing of data
'Action - (when) Starting up
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ReloadUSB()
MSGBoxName = "[J] JelleWie"
ButtonConnectDisconnect.Select()
RunOnStartup()
End Sub
'Button - Reload USB
Private Sub ComboBoxPoort_USBIndexChanged(sender As Object, e As EventArgs) Handles ComboBoxUSB.Click
ReloadUSB()
End Sub
'Code - Reload USB
Sub ReloadUSB()
PrefUSB = ComboBoxUSB.SelectedItem
ComboBoxUSB.Items.Clear()
On Error GoTo ErrHand
myPort = IO.Ports.SerialPort.GetPortNames()
ComboBoxUSB.Items.AddRange(myPort)
ComboBoxUSB.SelectionStart.ToString()
ComboBoxUSB.SelectedItem = PrefUSB
If ComboBoxUSB.SelectedItem = "" Then
ComboBoxUSB.SelectedItem = "COM10"
ComboBoxUSB.SelectedItem = "COM9"
ComboBoxUSB.SelectedItem = "COM8"
ComboBoxUSB.SelectedItem = "COM7"
ComboBoxUSB.SelectedItem = "COM6"
ComboBoxUSB.SelectedItem = "COM5"
ComboBoxUSB.SelectedItem = "COM4"
ComboBoxUSB.SelectedItem = "COM3"
ComboBoxUSB.SelectedItem = "COM2"
ComboBoxUSB.SelectedItem = "COM1"
ComboBoxUSB.SelectedItem = "COM0"
End If
ErrHand:
End Sub
'Button - Send
Private Sub ButtonSend_Click(sender As Object, e As EventArgs) Handles ButtonSend.Click
SerialSend()
End Sub
'Button - Enter Pressed (Send)
Private Sub TextBoxInput_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBoxInput.KeyDown
If e.KeyCode = Keys.Enter Then
SerialSend()
End If
End Sub
'Code - Serial send
Sub SerialSend()
RunOnSend()
If ButtonConnectDisconnect.Text = "Connect" Then
ButtonConnectDisconnect.Select()
ButtonSelected = ActiveControl.Name
MSG = "Where te hell should I write to?!" + Chr(13) + "try connecting first!"
Dim result As Integer = MessageBox.Show(MSG, MSGBoxName, MessageBoxButtons.OKCancel)
If result = DialogResult.Cancel Then
ElseIf result = DialogResult.OK Then
MsgBox("If your the programmer, Here is your solution" + Chr(13) + Chr(13) + "Put 'Enabled' in the properties of " + ButtonSelected + " to False" + Chr(13) + Chr(13) + "ADD " + Chr(13) + ButtonSelected + ".Enabled = True" + Chr(13) + "TO 'Sub RunOnConnect()'" + Chr(13) + Chr(13) + "ADD " + Chr(13) + ButtonSelected + ".Enabled =False" + Chr(13) + "TO 'Sub RunOnDisconnect()'")
End If
Else
RichTextBoxOutput.Text = ""
On Error GoTo ErrHand
SerialPort1.Write(TextBoxInput.Text)
End If
Exit Sub
ErrHand:
MsgBox("You couldn't resist to remove the cable didn't you?", , MSGBoxName)
Disconnect()
End Sub
'Button - Connect and Disconnect
Private Sub ButtonButtonConnectDisconnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonConnectDisconnect.Click
If ButtonConnectDisconnect.Text = "Connect" Then
'Connect
Connect()
Else
'Disconnect
ButtonConnectDisconnect.Text = "Connect"
ButtonConnectDisconnect.ForeColor = Color.Green
Disconnect()
End If
End Sub
'Code - Connect
Sub Connect()
If ComboBoxUSB.Text <> "" Then
On Error GoTo ErrHand
SerialPort1.PortName = ComboBoxUSB.Text
SerialPort1.BaudRate = 9600
SerialPort1.Open()
ComboBoxUSB.Enabled = False
ButtonSend.Enabled = True
TextBoxInput.Enabled = True
ButtonConnectDisconnect.Text = "Disconnect"
ButtonConnectDisconnect.ForeColor = Color.Red
TextBoxInput.Select()
RunOnConnect()
Else
MsgBox("I can not connect to nothing! what where you thinking..." + Chr(13) + "Please give me a COM poort to connect to, before letting me try to connect to it", , MSGBoxName)
ReloadUSB()
End If
Exit Sub
ErrHand:
MsgBox("The COM Port your trying to use, does not seems to work annymore" + Chr(13) + "Did you remove the cable again?", , MSGBoxName)
ReloadUSB()
ButtonConnectDisconnect.Select()
End Sub
'Code - Disconnect
Sub Disconnect()
ComboBoxUSB.Enabled = True
ButtonSend.Enabled = False
TextBoxInput.Enabled = False
ButtonConnectDisconnect.Text = "Connect"
ButtonConnectDisconnect.ForeColor = Color.Green
ButtonConnectDisconnect.Select()
RunOnDisconnect()
On Error GoTo ErrHand
SerialPort1.Close()
Exit Sub
ErrHand:
ReloadUSB()
End Sub
'Action - Recieved serial data
Private Sub SerialPort1_DataReceived(ByVal sender As System.Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
System.Threading.Thread.Sleep(5)
ReceivedText(SerialPort1.ReadExisting())
End Sub
'Code - Recieved serial data
Private Sub ReceivedText(ByVal [text] As String) 'input from ReadExisting
On Error GoTo ErrHand
If Me.RichTextBoxOutput.InvokeRequired Then
Dim x As New SetTextCallback(AddressOf ReceivedText)
Me.Invoke(x, New Object() {(text)})
Else
Me.RichTextBoxOutput.Text &= [text] 'append text
ArduinoAnswer = [text]
RunOnDataRecieved()
End If
Exit Sub
ErrHand:
MsgBox("Error while recieving data", , MSGBoxName)
End Sub
'==================================================
'==================================================
'========== Your Codes ==========
'==================================================
'==================================================
'Action - (when) sending data
Sub RunOnSend()
'Code to run befor sending data
TextBoxInput.Text = ClamFrontState & LeftState & FrontState & RightState
RichTextBoxOutput.Text = ""
PictureBox1.BackColor = Color.Orange
ButtonL0.BackColor = ButtonClose.BackColor
ButtonL1.BackColor = ButtonClose.BackColor
ButtonL2.BackColor = ButtonClose.BackColor
ButtonL3.BackColor = ButtonClose.BackColor
If LeftState = 0 Then
ButtonL0.BackColor = Color.Green
ElseIf LeftState = 1 Then
ButtonL1.BackColor = Color.Green
ElseIf LeftState = 2 Then
ButtonL2.BackColor = Color.Green
ElseIf LeftState = 3 Then
ButtonL3.BackColor = Color.Green
End If
ButtonF0.BackColor = ButtonClose.BackColor
ButtonF1.BackColor = ButtonClose.BackColor
ButtonF2.BackColor = ButtonClose.BackColor
ButtonF3.BackColor = ButtonClose.BackColor
If FrontState = 0 Then
ButtonF0.BackColor = Color.Green
ElseIf FrontState = 1 Then
ButtonF1.BackColor = Color.Green
ElseIf FrontState = 2 Then
ButtonF2.BackColor = Color.Green
ElseIf FrontState = 3 Then
ButtonF3.BackColor = Color.Green
End If
ButtonR0.BackColor = ButtonClose.BackColor
ButtonR1.BackColor = ButtonClose.BackColor
ButtonR2.BackColor = ButtonClose.BackColor
ButtonR3.BackColor = ButtonClose.BackColor
If RightState = 0 Then
ButtonR0.BackColor = Color.Green
ElseIf RightState = 1 Then
ButtonR1.BackColor = Color.Green
ElseIf RightState = 2 Then
ButtonR2.BackColor = Color.Green
ElseIf RightState = 3 Then
ButtonR3.BackColor = Color.Green
End If
Button1.BackColor = ButtonClose.BackColor
Button2.BackColor = ButtonClose.BackColor
If ClamFrontState = 1 Then
Button2.BackColor = Color.Green
Else
Button1.BackColor = Color.Green
End If
End Sub
'Action - (when) starting up
Sub RunOnStartup()
ResetCubeState()
ReloadUSB()
MSGBoxName = "[J] Rubiks Cube Solver"
ButtonConnectDisconnect.Select()
End Sub
'Action - (when) Connect
Sub RunOnConnect()
SerialSend()
ButtonArduino.Enabled = True
End Sub
'Action - (when) Disconnect
Sub RunOnDisconnect()
'This diables the Example button. so you can not send data when there is no connection
Button1.Enabled = False
ButtonArduino.Enabled = False
End Sub
'Action - (when) Serial data recieved
Sub RunOnDataRecieved()
MsgBox(ArduinoAnswer)
If ArduinoAnswer = "1" Then
PictureBox1.BackColor = Color.Green
ElseIf ArduinoAnswer = "E" Then
SerialSend()
PictureBox1.BackColor = Color.Blue
End If
End Sub
'==================================================
'==================================================
'========== More Codes ==========
'==================================================
'==================================================
'Code - Reset Cube state
Sub ResetCubeState()
LeftState = 0
FrontState = 0
RightState = 0
ClamFrontState = 0
End Sub
'Code - Reset all
Sub ResetAll()
TextBoxInput.Text = 1111
SerialSend()
RichTextBoxOutput.Text = ""
ResetCubeState()
End Sub
'Codes- Connection stuff
Sub SerialTurnFrontInverse()
If FrontState > 2 Then
FrontState = FrontState - 3
Else
FrontState = FrontState + 1
End If
End Sub
Sub SerialTurnFront()
If FrontState < 1 Then
FrontState = FrontState + 3
Else
FrontState = FrontState - 1
End If
End Sub
Sub SerialTurnLeftInverse()
If LeftState > 2 Then
LeftState = LeftState - 3
Else
LeftState = LeftState + 1
End If
End Sub
Sub SerialTurnLeft()
If LeftState < 1 Then
LeftState = LeftState + 3
Else
LeftState = LeftState - 1
End If
End Sub
Sub SerialTurnRight()
If RightState > 2 Then
RightState = RightState - 3
Else
RightState = RightState + 1
End If
End Sub
Sub SerialTurnRightInverse()
If RightState < 1 Then
RightState = RightState + 3
Else
RightState = RightState - 1
End If
End Sub
'Buttons - All buttons
Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
ClamFrontState = 0
SerialSend()
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
ClamFrontState = 1
SerialSend()
End Sub
Private Sub ButtonL0_Click(sender As Object, e As EventArgs) Handles ButtonL0.Click
LeftState = 0
SerialSend()
End Sub
Private Sub ButtonL1_Click(sender As Object, e As EventArgs) Handles ButtonL1.Click
LeftState = 1
SerialSend()
End Sub
Private Sub ButtonL2_Click(sender As Object, e As EventArgs) Handles ButtonL2.Click
LeftState = 2
SerialSend()
End Sub
Private Sub ButtonL3_Click(sender As Object, e As EventArgs) Handles ButtonL3.Click
LeftState = 3
SerialSend()
End Sub
Private Sub ButtonF0_Click(sender As Object, e As EventArgs) Handles ButtonF0.Click
FrontState = 0
SerialSend()
End Sub
Private Sub ButtonF1_Click(sender As Object, e As EventArgs) Handles ButtonF1.Click
FrontState = 1
SerialSend()
End Sub
Private Sub ButtonF2_Click(sender As Object, e As EventArgs) Handles ButtonF2.Click
FrontState = 2
SerialSend()
End Sub
Private Sub ButtonF3_Click(sender As Object, e As EventArgs) Handles ButtonF3.Click
FrontState = 3
SerialSend()
End Sub
Private Sub ButtonR0_Click(sender As Object, e As EventArgs) Handles ButtonR0.Click
RightState = 0
SerialSend()
End Sub
Private Sub ButtonR1_Click(sender As Object, e As EventArgs) Handles ButtonR1.Click
RightState = 1
SerialSend()
End Sub
Private Sub ButtonR2_Click(sender As Object, e As EventArgs) Handles ButtonR2.Click
RightState = 2
SerialSend()
End Sub
Private Sub ButtonR3_Click(sender As Object, e As EventArgs) Handles ButtonR3.Click
RightState = 3
SerialSend()
End Sub
End Class
'
Imports System
Imports System.Threading
Imports System.IO.Ports
Imports System.ComponentModel
Public Class Serial_Data
Dim MSGBoxName As String
Dim MSG As String
Dim myPort As Array
Dim ArduinoAnswer As String
Dim ButtonSelected As String
Dim PrefUSB As String
'Put under this line your own strings
Dim LeftState As Integer
Dim FrontState As Integer
Dim RightState As Integer
Dim ClamFrontState As Integer
Delegate Sub SetTextCallback(ByVal [text] As String) 'Added to prevent threading errors during receiveing of data
'Action - (when) Starting up
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ReloadUSB()
MSGBoxName = "[J] JelleWie"
ButtonConnectDisconnect.Select()
RunOnStartup()
End Sub
'Button - Reload USB
Private Sub ComboBoxPoort_USBIndexChanged(sender As Object, e As EventArgs) Handles ComboBoxUSB.Click
ReloadUSB()
End Sub
'Code - Reload USB
Sub ReloadUSB()
PrefUSB = ComboBoxUSB.SelectedItem
ComboBoxUSB.Items.Clear()
On Error GoTo ErrHand
myPort = IO.Ports.SerialPort.GetPortNames()
ComboBoxUSB.Items.AddRange(myPort)
ComboBoxUSB.SelectionStart.ToString()
ComboBoxUSB.SelectedItem = PrefUSB
If ComboBoxUSB.SelectedItem = "" Then
ComboBoxUSB.SelectedItem = "COM10"
ComboBoxUSB.SelectedItem = "COM9"
ComboBoxUSB.SelectedItem = "COM8"
ComboBoxUSB.SelectedItem = "COM7"
ComboBoxUSB.SelectedItem = "COM6"
ComboBoxUSB.SelectedItem = "COM5"
ComboBoxUSB.SelectedItem = "COM4"
ComboBoxUSB.SelectedItem = "COM3"
ComboBoxUSB.SelectedItem = "COM2"
ComboBoxUSB.SelectedItem = "COM1"
ComboBoxUSB.SelectedItem = "COM0"
End If
ErrHand:
End Sub
'Button - Send
Private Sub ButtonSend_Click(sender As Object, e As EventArgs) Handles ButtonSend.Click
SerialSend()
End Sub
'Button - Enter Pressed (Send)
Private Sub TextBoxInput_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBoxInput.KeyDown
If e.KeyCode = Keys.Enter Then
SerialSend()
End If
End Sub
'Code - Serial send
Sub SerialSend()
RunOnSend()
If ButtonConnectDisconnect.Text = "Connect" Then
ButtonConnectDisconnect.Select()
ButtonSelected = ActiveControl.Name
MSG = "Where te hell should I write to?!" + Chr(13) + "try connecting first!"
Dim result As Integer = MessageBox.Show(MSG, MSGBoxName, MessageBoxButtons.OKCancel)
If result = DialogResult.Cancel Then
ElseIf result = DialogResult.OK Then
MsgBox("If your the programmer, Here is your solution" + Chr(13) + Chr(13) + "Put 'Enabled' in the properties of " + ButtonSelected + " to False" + Chr(13) + Chr(13) + "ADD " + Chr(13) + ButtonSelected + ".Enabled = True" + Chr(13) + "TO 'Sub RunOnConnect()'" + Chr(13) + Chr(13) + "ADD " + Chr(13) + ButtonSelected + ".Enabled =False" + Chr(13) + "TO 'Sub RunOnDisconnect()'")
End If
Else
RichTextBoxOutput.Text = ""
On Error GoTo ErrHand
SerialPort1.Write(TextBoxInput.Text)
End If
Exit Sub
ErrHand:
MsgBox("You couldn't resist to remove the cable didn't you?", , MSGBoxName)
Disconnect()
End Sub
'Button - Connect and Disconnect
Private Sub ButtonButtonConnectDisconnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonConnectDisconnect.Click
If ButtonConnectDisconnect.Text = "Connect" Then
'Connect
Connect()
Else
'Disconnect
ButtonConnectDisconnect.Text = "Connect"
ButtonConnectDisconnect.ForeColor = Color.Green
Disconnect()
End If
End Sub
'Code - Connect
Sub Connect()
If ComboBoxUSB.Text <> "" Then
On Error GoTo ErrHand
SerialPort1.PortName = ComboBoxUSB.Text
SerialPort1.BaudRate = 9600
SerialPort1.Open()
ComboBoxUSB.Enabled = False
ButtonSend.Enabled = True
TextBoxInput.Enabled = True
ButtonConnectDisconnect.Text = "Disconnect"
ButtonConnectDisconnect.ForeColor = Color.Red
TextBoxInput.Select()
RunOnConnect()
Else
MsgBox("I can not connect to nothing! what where you thinking..." + Chr(13) + "Please give me a COM poort to connect to, before letting me try to connect to it", , MSGBoxName)
ReloadUSB()
End If
Exit Sub
ErrHand:
MsgBox("The COM Port your trying to use, does not seems to work annymore" + Chr(13) + "Did you remove the cable again?", , MSGBoxName)
ReloadUSB()
ButtonConnectDisconnect.Select()
End Sub
'Code - Disconnect
Sub Disconnect()
ComboBoxUSB.Enabled = True
ButtonSend.Enabled = False
TextBoxInput.Enabled = False
ButtonConnectDisconnect.Text = "Connect"
ButtonConnectDisconnect.ForeColor = Color.Green
ButtonConnectDisconnect.Select()
RunOnDisconnect()
On Error GoTo ErrHand
SerialPort1.Close()
Exit Sub
ErrHand:
ReloadUSB()
End Sub
'Action - Recieved serial data
Private Sub SerialPort1_DataReceived(ByVal sender As System.Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
System.Threading.Thread.Sleep(5)
ReceivedText(SerialPort1.ReadExisting())
End Sub
'Code - Recieved serial data
Private Sub ReceivedText(ByVal [text] As String) 'input from ReadExisting
On Error GoTo ErrHand
If Me.RichTextBoxOutput.InvokeRequired Then
Dim x As New SetTextCallback(AddressOf ReceivedText)
Me.Invoke(x, New Object() {(text)})
Else
Me.RichTextBoxOutput.Text &= [text] 'append text
ArduinoAnswer = [text]
RunOnDataRecieved()
End If
Exit Sub
ErrHand:
MsgBox("Error while recieving data", , MSGBoxName)
End Sub
'==================================================
'==================================================
'========== Your Codes ==========
'==================================================
'==================================================
'Action - (when) sending data
Sub RunOnSend()
'Code to run befor sending data
TextBoxInput.Text = ClamFrontState & LeftState & FrontState & RightState
RichTextBoxOutput.Text = ""
PictureBox1.BackColor = Color.Orange
ButtonL0.BackColor = ButtonClose.BackColor
ButtonL1.BackColor = ButtonClose.BackColor
ButtonL2.BackColor = ButtonClose.BackColor
ButtonL3.BackColor = ButtonClose.BackColor
If LeftState = 0 Then
ButtonL0.BackColor = Color.Green
ElseIf LeftState = 1 Then
ButtonL1.BackColor = Color.Green
ElseIf LeftState = 2 Then
ButtonL2.BackColor = Color.Green
ElseIf LeftState = 3 Then
ButtonL3.BackColor = Color.Green
End If
ButtonF0.BackColor = ButtonClose.BackColor
ButtonF1.BackColor = ButtonClose.BackColor
ButtonF2.BackColor = ButtonClose.BackColor
ButtonF3.BackColor = ButtonClose.BackColor
If FrontState = 0 Then
ButtonF0.BackColor = Color.Green
ElseIf FrontState = 1 Then
ButtonF1.BackColor = Color.Green
ElseIf FrontState = 2 Then
ButtonF2.BackColor = Color.Green
ElseIf FrontState = 3 Then
ButtonF3.BackColor = Color.Green
End If
ButtonR0.BackColor = ButtonClose.BackColor
ButtonR1.BackColor = ButtonClose.BackColor
ButtonR2.BackColor = ButtonClose.BackColor
ButtonR3.BackColor = ButtonClose.BackColor
If RightState = 0 Then
ButtonR0.BackColor = Color.Green
ElseIf RightState = 1 Then
ButtonR1.BackColor = Color.Green
ElseIf RightState = 2 Then
ButtonR2.BackColor = Color.Green
ElseIf RightState = 3 Then
ButtonR3.BackColor = Color.Green
End If
Button1.BackColor = ButtonClose.BackColor
Button2.BackColor = ButtonClose.BackColor
If ClamFrontState = 1 Then
Button2.BackColor = Color.Green
Else
Button1.BackColor = Color.Green
End If
End Sub
'Action - (when) starting up
Sub RunOnStartup()
ResetCubeState()
ReloadUSB()
MSGBoxName = "[J] Rubiks Cube Solver"
ButtonConnectDisconnect.Select()
End Sub
'Action - (when) Connect
Sub RunOnConnect()
SerialSend()
ButtonArduino.Enabled = True
End Sub
'Action - (when) Disconnect
Sub RunOnDisconnect()
'This diables the Example button. so you can not send data when there is no connection
Button1.Enabled = False
ButtonArduino.Enabled = False
End Sub
'Action - (when) Serial data recieved
Sub RunOnDataRecieved()
MsgBox(ArduinoAnswer)
If ArduinoAnswer = "1" Then
PictureBox1.BackColor = Color.Green
ElseIf ArduinoAnswer = "E" Then
SerialSend()
PictureBox1.BackColor = Color.Blue
End If
End Sub
'==================================================
'==================================================
'========== More Codes ==========
'==================================================
'==================================================
'Code - Reset Cube state
Sub ResetCubeState()
LeftState = 0
FrontState = 0
RightState = 0
ClamFrontState = 0
End Sub
'Code - Reset all
Sub ResetAll()
TextBoxInput.Text = 1111
SerialSend()
RichTextBoxOutput.Text = ""
ResetCubeState()
End Sub
'Codes- Connection stuff
Sub SerialTurnFrontInverse()
If FrontState > 2 Then
FrontState = FrontState - 3
Else
FrontState = FrontState + 1
End If
End Sub
Sub SerialTurnFront()
If FrontState < 1 Then
FrontState = FrontState + 3
Else
FrontState = FrontState - 1
End If
End Sub
Sub SerialTurnLeftInverse()
If LeftState > 2 Then
LeftState = LeftState - 3
Else
LeftState = LeftState + 1
End If
End Sub
Sub SerialTurnLeft()
If LeftState < 1 Then
LeftState = LeftState + 3
Else
LeftState = LeftState - 1
End If
End Sub
Sub SerialTurnRight()
If RightState > 2 Then
RightState = RightState - 3
Else
RightState = RightState + 1
End If
End Sub
Sub SerialTurnRightInverse()
If RightState < 1 Then
RightState = RightState + 3
Else
RightState = RightState - 1
End If
End Sub
'Buttons - All buttons
Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
ClamFrontState = 0
SerialSend()
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
ClamFrontState = 1
SerialSend()
End Sub
Private Sub ButtonL0_Click(sender As Object, e As EventArgs) Handles ButtonL0.Click
LeftState = 0
SerialSend()
End Sub
Private Sub ButtonL1_Click(sender As Object, e As EventArgs) Handles ButtonL1.Click
LeftState = 1
SerialSend()
End Sub
Private Sub ButtonL2_Click(sender As Object, e As EventArgs) Handles ButtonL2.Click
LeftState = 2
SerialSend()
End Sub
Private Sub ButtonL3_Click(sender As Object, e As EventArgs) Handles ButtonL3.Click
LeftState = 3
SerialSend()
End Sub
Private Sub ButtonF0_Click(sender As Object, e As EventArgs) Handles ButtonF0.Click
FrontState = 0
SerialSend()
End Sub
Private Sub ButtonF1_Click(sender As Object, e As EventArgs) Handles ButtonF1.Click
FrontState = 1
SerialSend()
End Sub
Private Sub ButtonF2_Click(sender As Object, e As EventArgs) Handles ButtonF2.Click
FrontState = 2
SerialSend()
End Sub
Private Sub ButtonF3_Click(sender As Object, e As EventArgs) Handles ButtonF3.Click
FrontState = 3
SerialSend()
End Sub
Private Sub ButtonR0_Click(sender As Object, e As EventArgs) Handles ButtonR0.Click
RightState = 0
SerialSend()
End Sub
Private Sub ButtonR1_Click(sender As Object, e As EventArgs) Handles ButtonR1.Click
RightState = 1
SerialSend()
End Sub
Private Sub ButtonR2_Click(sender As Object, e As EventArgs) Handles ButtonR2.Click
RightState = 2
SerialSend()
End Sub
Private Sub ButtonR3_Click(sender As Object, e As EventArgs) Handles ButtonR3.Click
RightState = 3
SerialSend()
End Sub
End Class