Disclaimer: This library is implemented to work with a specific version of the codie robots, that don't use the routing parameter. If you have a robot that doesn't work with this, feel free to submit an issue on GitHub. I'll contact you for further details and we'll try to add support for that as well. Let's make it a true community project!
A Node.js module to control a Codie robot. This module was written originally for a codie-server component that allows a Codie to be controlled remotely or use them in apps like Skratch(X), but generalized enough to use it in other custom apps.
This module is licensed under AGPL, please take this into consideration when re-using.
This module uses noble to communicate over bluetooth, and noble has some heavy requirements. Setting up on a mac is fairly easy, you only need xcode, and node-gyp, but on Windows it' a whole different story. Please see noble's documentation for more info.
npm install codiejs
var codie = new Codie("Codie_001"); // pass your codie's name to the constructor
codie.connect(function (error) {
if (!error) {
// do something with codie
}
});
codie.move (distance, leftSpeed, rightSpeed, cb);
codie.enableMotorBoth (leftSpeed, rightSpeed, cb);
codie.enableMotorLeft (speed, cb);
codie.enableMotorRight (speed, cb);
Note:
- positive speed -> left turn
- negative speed -> right turn
codie.turn (angle, speed, cb);
codie.beep (volume, frequency, duration, cb);
codie.setColor (hue, saturation, value, cb);
Possible animation values: 0, 1
codie.setAnimation (animation, hue, saturation, repeat, speed, cb);
codie.getDistance (cb(sensorData));
codie.getBattery (cb(sensorData));
codie.getSound (cb(sensorData));
codie.getLight (cb(sensorData));
codie.getLine (cb(sensorData));