That's not how it works. Each side runs its own code, entirely unaware of what is on the other side (other than something is supposed to be there). They communicate solely through serial-over-USB.
- sketch on Arduino
- built-in serial with
Serial
- built-in serial with
- form on VFP (the sample code below from that thread you linked)
- a form component that wraps an object that can send information to the serial port
After assigning a few settings properties, data is sent by assigning to thePUBLIC oForm oForm = CREATEOBJECT("Form") oForm.ADDOBJECT("comm", "olecontrol", "MSCommLib.MSComm") WITH oForm.comm .CommPort = 1 && Set to your COM port number .Settings = "9600,N,8,1" && Match baud rate and settings .PortOpen = .T. && Open the port ENDWITH * Send "Hello World" to Arduino oForm.comm.Output = "Hello World" + CHR(13) + CHR(10)
Output
property.
- a form component that wraps an object that can send information to the serial port
In that case, the bits flow in the other direction. On the Arduino, you'd use Serial.print
. In VFP, you apparently read the Input
property, either by
- constantly polling it
- hooking an event that tells you when data arrives
I did not find any official documentation online, but there is a Word doc from the University of Iowa that (at least partially) explains this, and some old forum threads in various places. Relevant properties include
OnComm
RThreshold
InputLen
InBufferSize