Hello ALL,
How is it possible to use the pins named "DIGITAL" as digital INs?
First choose the programming language you want to use for building an interface (GUI).
Second you set the I/O as either "high" or "low" to receive and send data, so if you wanted to use I/O Number 9 to turn a servo motor either right or left you can do it pretty easily.
Here is some VB.NET 2010 code for the computer side, AKA your GUI.
All you need are two buttons...
Imports System.IO
Imports System.IO.Ports
Imports System.Threading
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
With SerialPort1
SerialPort1.Close()
SerialPort1.PortName = "com4" 'change com port to match your Arduino port
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!
End With
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
SerialPort1.Open()
SerialPort1.Write("3")
SerialPort1.Close()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
SerialPort1.Open()
SerialPort1.Write("4")
SerialPort1.Close()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
End
End Sub
As you can see the "SerialPort1.Write("4")" and "SerialPort1.Write("3")" under each button are the commands being sent to the Arduino threw USB in the form of a packet.
As you can imagine the sketch has the number 3 and 4 defined as I/O 9 and each one moves the motor 180 degrees from each other.
Hope this helps,
Rob
http://whatisacnc.com