Rörelse kontrollerad RGB ledde kostym med Xbox 360 Kinect, Max MSP och Arduino Del1 (4 / 4 steg)
Steg 4: Aurduino
Bara hämta koden nedan och ladda upp den till din arduino.CONST int LEDone = 9;
CONST int LEDtwo = 11;
CONST int LEDthree = 10;
CONST int LEDfour = 5;
CONST int LEDfive = 6;
CONST int LEDsix = 3;
int currentPin = 0;
int ljusstyrka = 0;
void setup() {
Serial.BEGIN(9600);
pinMode (LEDone, OUTPUT);
pinMode (LEDtwo, OUTPUT);
pinMode (LEDthree, OUTPUT);
pinMode (LEDfour, OUTPUT);
pinMode (LEDfive, OUTPUT);
pinMode (LEDsix, OUTPUT);
}
void loop() {
IF(Serial.available() > 0) {
int inByte = Serial.read();
Serial.write(inByte);
om (inByte == "a") {
currentPin = LEDone;
}
om (inByte == "b")
{currentPin = LEDtwo;}
om (inByte == "c")
{currentPin = LEDthree;}
om (inByte == hade ") {
currentPin = LEDfour;
}
om (inByte == "e")
{currentPin = LEDfive;}
om (inByte == "f")
{currentPin = LEDsix;}
om (inByte > = 0 & & inByte < = 255) {
ljusstyrka = inByte;
analogWrite (currentPin, ljusstyrka);
}
}
}
Du kommer antagligen behöva ändra portinformationen i MAX på filen jag gav dig att få arduino att prata med MAX. Andra kloka du bör vara bra att gå.