[chuck-users] Serial/Arduino & ChucK example

Steve Morris steve at judgement.com
Wed Jan 1 20:04:10 EST 2014


Just some random thoughts while waiting for your answer: Note I have never
connected ChucK to a serial port but I have talked to an arduino in other
languages (processing most recently) so I can probably help. I'm using a
Macintosh but since it is UNIX based it shouldn't be that different from
Linux methodology.

o- I assume you will be using a USB serial port to talk to the arduino.
Have you used this on the arduino already?

o- If you don't find a working example you'll need to break it down. I
would get the arduino going first using terminal software to debug it.

o- The key to getting two devices to talk without lots of fragile debugging
is to create some core software on both sides that you can debug once and
seldom change. This core generally implements some simple command/ response
protocol. Once that works you build out from it in both directions by
adding new commands.

o- the ChucK part of the software should probably be in its own thread. The
rest of the system interacts with the thread through common variables. Only
that thread should know anything about the arduino. You can imagine a
thread which continuously polls the arduino for pot data and writes the
values into an array. when other parts of the software need to know a pot
value it looks in the array. Again this allows you to write the whole
arduino interface stuff once and never change it. especially the comm part.
It also lets you change your mind and use a raspberry pi with wifi instead.
or maybe you'll find a cheap midi controller with sliders somewhere. The
rest of the code just uses the array and doesn't care how the data got
there.

Fortunately the USB serial port is very reliable. you shouldn't need to
bother with error checking and resending data

o- you need to decide which is the master and which the slave. It can be
done either way especially with slow devices like pots. It's probably a
little easier to debug if the arduino is the slave.

You probably detect a little paranoia on my suggestions. There is nothing
inherently difficult in this but if you don't do it right it can be a
killer to debug mostly because you can't easily see what is happening on
the wire.

Once you get the communication parameters to match it should be pretty
simple.

On Wednesday, January 1, 2014, Steve Morris wrote:

> Are you looking for advice on the arduino side or the ChucK side?
>
> On Wednesday, January 1, 2014, Alan Brooker wrote:
>
>> Hi there
>>
>> I am using ChucK 1.3.2.0 (Chimera) with miniAudicle 1.3.0a on Ubuntu
>> 12.04- I think the latest version can communicate with Arduino directly?
>> Cant seem to find any examples so any advice  or example code would be much
>> appreciated. I am trying to build a simple step sequencer with *x5
>> potentiometer*s that send values to an arduino board and then into ChucK
>> hopefully. Was hoping I could do this without OSC-
>>
>> thanks for helping this noob!
>>
>>
>>
>> Al
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20140101/a72a2c8e/attachment-0001.htm>


More information about the chuck-users mailing list