Sunday, September 20, 2015

Accelerometer driven led


The Accelerometer is driving the color of the led. The one thing that helped the most on this project was finding out the output voltages of the pins on the accelerometer. The Arduino reads from 0-5 volts and maps those values from 0-1024 I believe.  But the accelerometer puts out a smaller range of voltages so you have to convert those to a broader range of values if you want your led to have a more drastic change in color. We did not connect capacitors to the outputs and i think that would have helped especially with the flickering you see in the video below. 



void setup() {
  Serial.begin(9600);
}
void loop() {
  int xVal = analogRead(A2);
  int yVal = analogRead(A1);
  int zVal = analogRead(A0);
  int red = 9;
  int green = 10;
  int blue = 11;
  pinMode(red, OUTPUT);
  pinMode(green, OUTPUT);
  pinMode(blue, OUTPUT);
  float rr = (xVal - 180.0) * (255.0 / 328.0);
  float gg = (yVal - 180.0) * (255.0 / 328.0);
  float bb = (zVal - 180.0) * (255.0 / 328.0);
  analogWrite(red, rr);
  analogWrite(green, gg);
  analogWrite(blue, bb);

  //Serial.println(xVal);
  Serial.println(rr);
}


Tuesday, September 15, 2015

Interactive Kinetic Sculpture / Do nothing machine

This is a prototype for an interactive kinetic sculpture. The users would first start the Arduino and hear a beeping. Then they are able to control how fast different part of the sculpture rotates with two knobs. LEDs shift hues according to the rpm of the motors. This is the second this has been assembled. 







/* Matthew Justice
 Physical Computing 
 Interactive Kinetic Sculpture with leds 
 Do nothing machine
*/


int motorPin = 5;
int motor = 6;

//beeps on start up 


void beep(unsigned char delayms) {
  analogWrite(3, 20);
  delay(delayms);
  analogWrite(3, 0);
  delay(delayms);
}



void setup() {
  pinMode(motorPin, OUTPUT);
  pinMode(motor, OUTPUT);
  Serial.begin(9600);
  pinMode(3, OUTPUT);

  pinMode(3, OUTPUT);
  beep(100);
  delay(50);
  beep(60);
  delay(50);
  beep(125);

}

int rr = 255;
int gg = 255;
int bb = 255;
int red = 9;
int green = 10;
int blue = 11;


void loop()
{
  //beep(1);
  int sensor = analogRead(A0);
  float rpm = sensor * (255 / 1024.0);

  int sensort = analogRead(A1);
  float rpmt = sensort * (255 / 1024.0);

  int speeed = rpm;
  int speeedt = rpmt;
  analogWrite(motorPin, speeed);
  analogWrite(motor, speeedt);
  Serial.println(rpmt);

  pinMode(red, OUTPUT);
  pinMode(green, OUTPUT);
  pinMode(blue, OUTPUT);

  int sensorValue = analogRead(A0);
  float volt = sensorValue * (360 / 1024.0);



  if (volt < 60) {
    rr = 0;
  }
  if (volt >= 120 && volt <= 240 ) {
    rr = 255;
  }
  if (volt >= 300) {
    rr = 0;
  }
  if (volt >= 60 && volt <= 180) {
    gg = 0;
  }
  if (volt >= 240 ) {
    gg = 255;
  }
  if (volt < 120 ) {
    bb = 255;
  }
  if (volt >= 180 && volt <= 300) {
    bb = 0;
  }

  // linear color change

  if (volt < 60 ) {
    gg = (255 / 60) * volt;
    gg = 255 - gg;
    gg = abs(gg);
  }

  if (volt >= 120 && volt <= 180) {
    bb = (255 / 60) * (volt - 120);
    bb = 255 - bb;
    bb = abs(bb);
  }

  if (volt >= 240 && volt <= 300) {
    rr = (255 / 60) * (volt - 240);
    rr = 255 - rr;
    rr = abs(rr);
  }

  if (volt >= 180 && volt <= 240) {
    gg = -1 * ((255 / 60) * (volt - 180));
    gg = 255 - gg;
    gg = abs(gg);
  }

  if (volt >= 60 && volt <= 120) {
    rr = -1 * ((255 / 60) * (volt - 60));
    rr = 255 - rr;
    rr = abs(rr);
  }

  if (volt >= 300 && volt <= 360) {
    bb = -1 * ((255 / 60) * (volt - 300));
    bb = 255 - bb;
    bb = abs(bb);
  }


  analogWrite(red, rr);
  analogWrite(green, gg);
  analogWrite(blue, bb);

}



Tuesday, September 8, 2015

Matt Justice RYB led controller Arduino code

//Matt Justice RYB led controller

void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}


int rr = 255;
int gg = 255;
int bb = 255;
int red = 9;
int green = 10;
int blue = 11;



// the loop routine runs over and over again forever:
void loop() {

  pinMode(red, OUTPUT);
  pinMode(green, OUTPUT);
  pinMode(blue, OUTPUT);


  int sensorValue = analogRead(A0);
  float volt = sensorValue * (360 / 1024.0);

  if (volt < 60) {
    rr = 0;
  }
  if (volt >= 120 && volt <= 240 ) {
    rr = 255;
  }
  if (volt >= 300) {
    rr = 0;
  }
  if (volt >= 60 && volt <= 180) {
    gg = 0;
  }
  if (volt >= 240 ) {
    gg = 255;
  }
  if (volt < 120 ) {
    bb = 255;
  }
  if (volt >= 180 && volt <= 300) {
    bb = 0;
  }

  // linear color change

  if (volt < 60 ) {
    gg = (255 / 60) * volt;
    gg = 255 - gg;
    gg = abs(gg);
  }

  if (volt >= 120 && volt <= 180) {
    bb = (255 / 60) * (volt - 120);
    bb = 255 - bb;
    bb = abs(bb);
  }

  if (volt >= 240 && volt <= 300) {
    rr = (255 / 60) * (volt - 240);
    rr = 255 - rr;
    rr = abs(rr);
  }

  if (volt >= 180 && volt <= 240) {
    gg = -1 * ((255 / 60) * (volt - 180));
    gg = 255 - gg;
    gg = abs(gg);
  }

  if (volt >= 60 && volt <= 120) {
    rr = -1 * ((255 / 60) * (volt - 60));
    rr = 255 - rr;
    rr = abs(rr);
  }

  if (volt >= 300 && volt <= 360) {
    bb = -1 * ((255 / 60) * (volt - 300));
    bb = 255 - bb;
    bb = abs(bb);
  }

  analogWrite(red, rr);
  analogWrite(green, gg);
  analogWrite(blue, bb);


  // Serial.println(volt);
  // Serial.println(rr);
  // Serial.println(gg);
  // Serial.println(bb);

}





Monday, September 7, 2015

Model for Fantasy Artwork

My idea to incorporate an Arduino into an art piece is to make a modern day do nothing machine.

"In 1957, the Eameses designed the SOLAR DO-NOTHING MACHINE. True to the Eameses' belief that toys are not as innocent as they appear, the machine was one of the first uses of solar power to produce electricity."


My plan is to instead of showing how solar power can create art, to show how an interactive computer experience can invoke a feeling of wonder and whimsy in the audience.

The piece will have some buttons, switches and dials that can start and stop movements, create different lights, and adjust the speed of various things.