As computing becomes more ubiquitous in our objects, designers need to be more aware of how to design meaningful interactions into electronically enhanced objects. At the University of Washington, a class of junior Interaction Design majors is exploring this question. These pages chronicle their efforts.

Wednesday, December 12, 2018

Actuator Experiment - 3 Colored LED



For the Actuator experiment, we worked with the RGB LED light. We wanted to play around with timing and switching colors. The tutorial we followed showed us how to program the LED to change colors on a specific schedule. The tutorial can be found here: https://learn.adafruit.com/adafruit-arduino-lesson-3-rgb-leds/other-things-to-do

The LED had 4 Arduino connections, 1 to ground and the 3 others to pins, each correlated to red, green, and blue. Here is the board/Arduino layout:

learn_arduino_fritzing.jpg

We started by experimenting with pure red, green and blue lights. We wanted to change the colors, so we looked online and found values we liked. We used (255, 0, 0) for red, (255, 165, 0) for orange, (255, 255, 0) for yellow, (0, 128, 0) for green, and (0, 255, 255) for teal blue.


Arduino Code: 

int redPin = 11;
int greenPin = 10;
int bluePin = 9;

//uncomment this line if using a Common Anode LED
//#define COMMON_ANODE

void setup()
{
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT);  
}

void loop()
{
  setColor(255, 0, 0);  // red
  delay(1000);
  setColor(255, 165, 0);  // orange
  delay(1000);
  setColor(255, 255, 0);  // yellow
  delay(1000); 
  setColor(0, 128, 0); //green
  delay(1000);
  setColor(0, 255, 255); //blue
  delay(1000);  

}

void setColor(int red, int green, int blue)
{
  #ifdef COMMON_ANODE
    red = 255 - red;
    green = 255 - green;
    blue = 255 - blue;
  #endif
  analogWrite(redPin, red);
  analogWrite(greenPin, green);
  analogWrite(bluePin, blue);  
}


No comments:

Post a Comment