Skip to content

Instantly share code, notes, and snippets.

@rdlucas2
Created July 16, 2016 14:55
Show Gist options
  • Save rdlucas2/4e2ac51ce4556783248b0837717772b0 to your computer and use it in GitHub Desktop.
Save rdlucas2/4e2ac51ce4556783248b0837717772b0 to your computer and use it in GitHub Desktop.
//node-serialport code:
var SerialPort = require('serialport');
var message = new Buffer('hi');
port.on('open', funciton() {
port.write(message, function(err) {
if(err) {
return console.log('Error on write: ', err.message);
}
console.log('message written');
});
});
port.on('error', function(err) {
console.log('Error: ', err.message);
});
//C++ code uploaded to arduino:
#include "MeOrion.h"
MeRGBLed led(PORT_3);
void setup()
{
Serial.begin(9600);
}
void loop()
{
if(Serial.available() > 0) {
String message = Serial.readString();
Serial.println(message);
if(message == "hi") {
led.setColorAt(0, 50, 0 , 0);
}
}
Serial.flush();
led.show()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment