Blenduino is an almost-plug-and-play solution for connection an Arduino (or other microcontroller!) to Blender, via Serial. This guide assumes that you are vaguely familiar with Ardunio Serial communication and comfortable with Blender (knowing what a Driver is will help).
Blender runs its own installation of python so there's a tiny amount of frontloading to get the Serial library to play nice. This guide walks through how to install modules in Blender's python. The only change you need to make is in step 3 install 'pyserial' instead of 'scikit-image'
Once you have installed python Serial as shown above, follow these steps to set up the Blenduino add on:
Clone or download this repo, and take note of where it is located.
Open up Blender, and go to File > User Preferences
In the Add-ons tab, click Install Add-on from File
Point the file explorer to the Blenduino repo. Select the blenduino.py file from Blendiuno/blender/addon/ and hit Install Add-on from File.
Back in the Add-on tab, select Testing under Supported Level, and User under Categories. Then check the box next to Tool: Blenduino to activate the Add-on. Don't forget to Save User Settings.
Still in User Preferences, navigate to the File tab, and make sure Auto Run Python Scripts is checked. This ensures that we are able to customise our drivers later on. Don't forget to Save User Settings.
Now you can exit User Preferences. There should be a new tab in your Tool Shelf called Serial.
The Serial tab exposes all the options you need to open a Serial port and listen for incoming data from an Arduino. For more on the settings, see Serial definitions.
- Serial Port: The easiest way to find this is to use the Arduino IDE.
- Baud Rate: This should match the baud rate of whatever sketch you are running (default 9600).
- Separator: A character to specify the separation of incoming values. In all the examples the separator character is ','
- Expected Length: How many [Separator] separated values are you expecting to receive?
- Start Serial: Toggle the Serial port on and off. Will throw an error if the wrong port is specified. Rememeber to Stop Serial if you want to upload new code to your board.
- Toggle Serial Debugging: Toggle whether to log incoming data on Blender's System Console.
- Data to Write: This is the data that will send out via Serial. Add a driver here to control what is sent.
Once you have entered your settings, click Start Serial to open the Serial Port and start listening for data. To check what you are receiving, go to Window > Toggle System Console.
You should see the data streaming past akin to the Arduino Serial Monitor. Note: closing the System Console closes Blender, so click away or toggle it off using the Window menu.
bpy.context.scene.serial_data[index]
Blenduino exposes incoming Serial data to Blender's scene context using serial_data[i]. If this doesn't make sense to you, watch this video below. The video explains how to access incoming Serial data and use that data to influence your scene.
How to set up drivers with Blenduino.
Within the Ardunio directory of this repo is a demo of how to send data from an Arduino to Blender, called Simple_Write_Test
bpy.context.scene.serial_write_data
Similarly to above, the data in the scene context at serial_write_data is what is written out to Serial.
The data can be accessed via the Serial tool panel, under the line item Data to Write. Add a driver here to control this data. Note that the data sent is an integer. All floats will be floored.
Within the Ardunio directory of this repo is a demo of how to read the data from Blender, called Simple_Read_Test