Writing to Arduino using R

I have an Arduino (Uno) connected to a macbook on MacOS 10.14 using USB and I am trying to exchange data using R.

Setting up a connection and reading data works fine, but writing data provokes an error and I am not sure what’s wrong. A working example:

#loading the R package for serial communication

#storing the appropriate serial device name
con_dir = "/dev/"
con_arduino_cu<-list.files(con_dir, pattern ="cu.usb")

#setting up connection parameters, making sure the BAUD rate matches the one used by the Arduino
con <- serialConnection(name = "testcon"
                       ,port = con_arduino_cu
                       ,mode = "9600,n,8,1"
                       ,buffering ="none"
                       ,newline = 1
                       ,translation = "cr"

#opening and testing the connection

#this reads that from the Arduino

#But this returns an error: 'Error: [tcl] can't read "tcl_tmp_cu": no such variable'
write.serialConnection(con,"Hello world")

I have tried using the ttl connection instead of the cu connection, but this makes R hang.

Any idea on whats wrong, or for alternative ways to write data over USB?

I am not sure what you expect with posting R code.
We don't use it here.

Have no idea what a "cu connection" is either.


This is (now?) in the "interfacing section" so any computer language should be OK.

OP might be better of in a forum for the specific language though.

OP, does your Arduino code work with a normal terminal program (e.g. serial monitor)?