Skip to content

Instantly share code, notes, and snippets.

@xseignard
Last active August 29, 2015 13:59
Show Gist options
  • Save xseignard/10891910 to your computer and use it in GitHub Desktop.
Save xseignard/10891910 to your computer and use it in GitHub Desktop.
String fromProcessing;
void setup() {
Serial.begin(9600);
pinMode(13, OUTPUT);
}
void loop() {
while (Serial.available() > 0) {
char recieved = Serial.read();
// si le caractère recu est le caractère de stop
if (recieved == '#') {
Serial.print(fromProcessing);
if(fromProcessing == "hello world") {
digitalWrite(13, HIGH);
}
else {
digitalWrite(13, LOW);
}
fromProcessing = "";
}
else {
fromProcessing += recieved;
}
}
}
@xseignard
Copy link
Author

import processing.serial.*;
Serial myPort;
void setup() {
  size(200, 200);
  String portName = Serial.list()[0]; // récupérer le premier des ports
  myPort = new Serial(this, portName, 9600); // ouvrir le port
}
void draw() {
  if (mousePressed) {
    myPort.write("hello world#"); // allumer la led
    background(255);
  } else {
    myPort.write("hello#"); // éteindre la led
    background(0);
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment