/* Physical Pixel An example of using the Arduino board to receive data from the computer. In this case, the Arduino boards turns on an LED when it receives the character 'H', and turns off the LED when it receives the character 'L'. The data can be sent from the Arduino Serial Monitor, or another program like Processing (see code below), Flash (via a serial-net proxy), PD, or Max/MSP. The circuit: - LED connected from digital pin 13 to ground created 2006 by David A. Mellis modified 30 Aug 2011 by Tom Igoe and Scott Fitzgerald This example code is in the public domain. http://www.arduino.cc/en/Tutorial/PhysicalPixel */ #include // Which pin on the Arduino is connected to the NeoPixels? #define PIN_rasa 9 // On Trinket or Gemma, suggest changing this to 1 #define PIN_saint 11 // On Trinket or Gemma, suggest changing this to 1 // How many NeoPixels are attached to the Arduino? #define NUMPIXELS 4 // Popular NeoPixel ring size // When setting up the NeoPixel library, we tell it how many pixels, // and which pin to use to send signals. Note that for older NeoPixel // strips you might need to change the third parameter -- see the // strandtest example for more information on possible values. Adafruit_NeoPixel rasa(NUMPIXELS, PIN_rasa, NEO_GRB + NEO_KHZ800); Adafruit_NeoPixel saint(NUMPIXELS, PIN_saint, NEO_GRB + NEO_KHZ800); int incomingByte; // a variable to read incoming serial data into void setup() { // initialize serial communication: Serial.begin(9600); rasa.begin(); // INITIALIZE NeoPixel strip object (REQUIRED) saint.begin(); rasa.clear(); // Set all pixel colors to 'off' saint.clear(); saint.setBrightness(180); rasa.setBrightness(30); } void colorWipe_saint(uint32_t color, int wait) { for(int i=0; i 0) { // read the oldest byte in the serial buffer: incomingByte = Serial.read(); // if it's a capital H (ASCII 72), turn on the LED: if (incomingByte == 'A') { colorWipe_saint(saint.Color(0, 0, 255), 50); // Red } // if it's an L (ASCII 76) turn off the LED: if (incomingByte == 'B') { colorWipe_saint(saint.Color(0, 0, 0), 50); // Off } if (incomingByte == 'C') { colorWipe_rasa(rasa.Color(255, 255, 0), 50); // Red } if (incomingByte == 'D') { colorWipe_rasa(rasa.Color(0, 0, 0), 50); // Red } } } /* Processing code for this example // Mouse over serial // Demonstrates how to send data to the Arduino I/O board, in order to turn ON // a light if the mouse is over a square and turn it off if the mouse is not. // created 2003-4 // based on examples by Casey Reas and Hernando Barragan // modified 30 Aug 2011 // by Tom Igoe // This example code is in the public domain. import processing.serial.*; float boxX; float boxY; int boxSize = 20; boolean mouseOverBox = false; Serial port; void setup() { size(200, 200); boxX = width / 2.0; boxY = height / 2.0; rectMode(RADIUS); // List all the available serial ports in the output pane. // You will need to choose the port that the Arduino board is connected to // from this list. The first port in the list is port #0 and the third port // in the list is port #2. // if using Processing 2.1 or later, use Serial.printArray() println(Serial.list()); // Open the port that the Arduino board is connected to (in this case #0) // Make sure to open the port at the same speed Arduino is using (9600bps) port = new Serial(this, Serial.list()[0], 9600); } void draw() { background(0); // Test if the cursor is over the box if (mouseX > boxX - boxSize && mouseX < boxX + boxSize && mouseY > boxY - boxSize && mouseY < boxY + boxSize) { mouseOverBox = true; // draw a line around the box and change its color: stroke(255); fill(153); // send an 'H' to indicate mouse is over square: port.write('H'); } else { // return the box to its inactive state: stroke(153); fill(153); // send an 'L' to turn the LED off: port.write('L'); mouseOverBox = false; } // Draw the box rect(boxX, boxY, boxSize, boxSize); } */ /* Max/MSP version 5 patch to run with this example: ----------begin_max5_patcher---------- 1672.3oc2ZszaaiCD9ryuBBebQVCQRYao8xhf1cQCPVfBzh8RRQ.sDsM2HSZ HQmlzh9eu7gjsjsEk7y0oWjiHoHm4aluYHGlueUmtiDuPy5B9Cv8fNc99Uc5 XZR2Pm726zcF4knDRlYXciDylQ4xtWa6SReQZZ+iSeMiEQR.ej8BM4A9C7OO kkAlSjQSAYTdbFfvA27o2c6sfO.Doqd6NfXgDHmRUCKkolg4hT06BfbQJGH3 5Qd2e8d.QJIQSow5tzebZ7BFW.FIHow8.2JAQpVIIYByxo9KIMkSjL9D0BRT sbGHZJIkDoZOSMuQT.8YZ5qpgGI3locF4IpQRzq2nDF+odZMIJkRjpEF44M3 A9nWAum7LKFbSOv+PSRXYOvmIhYiYpg.8A2LOUOxPyH+TjPJA+MS9sIzTRRr QP9rXF31IBZAHpV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