The Arduino IDE downloaded and worked fine on the RPi so it was able to use the Rpi USB to Arduino connection without any problem.
Although the FreeBasic Linux program compiled successfully it failed to execute with an error opening the com port.
error opening com3
The port address used by the Arduino IDE was shown as,
Port:"/dev/ttyACMO(Arduino/Genuine Mega or Mega 2560)"
So I changed:
Dim As String com_cmd = "COM3:9600,n,8,1,cs0,ds0,cd0,rs"
to,
Dim As String com_cmd = "/dev/ttyACMO(Arduino/Genuine Mega or Mega 2560):9600,n,8,1,cs0,ds0,cd0,rs"
without success so I assume Linux does the ports differently to Windows?
This was the FreeBasic code in question given by MrSwiss that works on Windows and I was trying to get to work with Linux (Raspian).
Code: Select all
screenres 640,480,32
Dim As Long fn = FreeFile
Dim As String com_cmd = "COM3:9600,n,8,1,cs0,ds0,cd0,rs"
If Open Com(com_cmd As #fn) <> 0 Then
Print "Error opening COM3"
Sleep 2000, 1
Cls
End 1
End If
dim as string outData, inData
do
outData = inkey
If outData <> "" Then
print #fn, outData ' SEND DATA
While LOC(fn) = 0 ' wait until ARDU responds
Sleep 20 ' (forever, if no answer!)
Wend
inData = ""
while Loc(fn) > 0
inData += Input(1,#fn) 'acknowledge data received
Wend
'print inData
End If
Sleep 20
loop until outData = "q" 'multikey(&H01)
Close #fn