Introduction:
The BlendixSerial library is designed to work in conjunction with the blendixserial addon in Blender. It allows for controlling objects in Blender using serial communication with an Arduino or other microcontrollers. The library provides functions to set coordinates and text for the objects in Blender, as well as retrieve a formatted output string.Installation:
- Download the library files from the given link.
- Extract the downloaded files.
- Copy the entire extracted folder into the Arduino libraries folder. The default location for this folder is:
- Windows: Documents\Arduino\libraries
- macOS: Documents/Arduino/libraries
- Linux: Documents/Arduino/libraries
- Restart the Arduino IDE if it was already open.
API Reference:
BlendixSerial class
BlendixSerial()
BlendixSerial()
- Constructor for the
BlendixSerial
class. - Initializes the
coordinates
array.
void resetCoordinates()
void resetCoordinates()
- Resets all coordinates in the
coordinates
array to zero.
void setCoordinates(int setNum, int xVal, int yVal, int zVal)
void setCoordinates(int setNum, int xVal, int yVal, int zVal)
- Sets the
x
,y
, andz
values for a specific set in thecoordinates
array. - Parameters:
setNum
(int): The set number (1 to 3).xVal
(int): Thex
value for the set.yVal
(int): They
value for the set.zVal
(int): Thez
value for the set.
void setText(String inputText)
void setText(String inputText)
- Sets the value of the
text
variable. - Parameters:
inputText
(String): The text to be set.
String getFormattedOutput()
String getFormattedOutput()
- Returns a formatted string containing the coordinates and text data.
- The coordinates are concatenated with commas and each set is separated by a semicolon.
- Example output:
"10,20,30;Hello, Blendix!"
Usage:
- Include the library at the top of your sketch:
- Create an instance of the
BlendixSerial
class: - Set the coordinates and text using the provided member functions:
- Retrieve the formatted output using the
getFormattedOutput()
function: - Use the output string as needed. For example, you can send it over a serial connection.
#include <BlendixSerial.h>
BlendixSerial blendix;
blendix.setCoordinates(1, 10, 20, 30);blendix.setText("Hello, Blendix!");
String output = blendix.getFormattedOutput();
The output string will contain the formatted coordinates and text data.
Example:
#include "BlendixSerial.h"
BlendixSerial blendix;
void setup() { Serial.begin(9600);}
void loop() { // Setting coordinates for set 1 blendix.setCoordinates(1, 10, 20, 30); // Setting text blendix.setText("Hello, Blendix!"); // Getting the formatted output String Output = blendix.getFormattedOutput(); // Printing the formatted output Serial.println(Output); delay(2000); // Resetting coordinates blendix.resetCoordinates(); // Updating text blendix.setText("Reset and Update"); // Getting the updated formatted output Output = blendix.getFormattedOutput(); // Printing the updated formatted output Serial.println(Output);
delay(2000);}
Note: Make sure to include the `BlendixSerial.h` header file and create an instance of the `BlendixSerial` class before using its methods.The BlendixSerial library can be used in combination with the BlendixSerial addon in Blender to control the objects' coordinates and text in real-time from an external device via serial communication. Refer to the provided example sketches in Library for more usage scenarios and ideas.