Created
July 16, 2016 14:55
-
-
Save rdlucas2/4e2ac51ce4556783248b0837717772b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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