Created
December 9, 2017 03:51
-
-
Save koji/9eed302ae72595cc2db799ae275d48ef to your computer and use it in GitHub Desktop.
arduino receive data from nodejs
This file contains hidden or 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
#define redPin * | |
#define greenPin * | |
#define bluePin * | |
int recieveByte = 0; | |
String bufStr = ""; | |
String okStr = "OK"; | |
void setup() { | |
// init pins | |
pinMode(redPin, OUTPUT); | |
pinMode(greenPin, OUTPUT); | |
pinMode(bluePin, OUTPUT); | |
Serial.begin(9600); | |
} | |
void loop() { | |
bufStr = ""; | |
while (Serial.available() > 0) { | |
recieveByte = Serial.read(); | |
if (recieveByte == (int)'\n') break; | |
bufferStr.concat((char)recieveByte); | |
} | |
if (bufferStr.length() > 0) { | |
analogWrite(redOin, ); | |
} | |
delay(500); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment