Amy & Amy
This week we began experimenting with various ways to control a multi colored LED. This will be the basis for our final prototype.
Our first step was to figure out how to get the LED to display red, then blue, then green light. After successfully coding that, we tried to transition from one color to another and have all three colors fade simultaneously. Our third step was to hook up a potentiometer to allow for the changing of the brightness of the LED. We started with a dial potentiometer, which could be twisted to fade in or out the light. From there we coded a soft potentiometer in addition to the dial. Depending on the area and how much pressure was exerted on the soft potentiometer, the LED would vary in color and intensity of color while the dial still controlled the brightness.
Pseudo Code:
//this sketch was using a conductive fabric controlling the current when in contact
#define REDLED 9
#define BLUELED 10
#define GREENLED 11
#define POT1 A0
int i = 0; // We’ll use this to count up and down
int brt = 0; // pot value
void setup() {
pinMode(REDLED, OUTPUT); // tell Arduino LED is an output
pinMode(BLUELED, OUTPUT); // tell Arduino LED is an output
pinMode(GREENLED, OUTPUT); // tell Arduino LED is an output
pinMode(POT1, INPUT); // tell Arduino LED is an output
}
void loop(){
brt = analogRead(POT1);
analogWrite(BLUELED, brt/5); // set the LED brightness
analogWrite(GREENLED, brt/5); // set the LED brightness
}
Pseudo Code:
//this sketch was using a conductive fabric controlling the current when in contact
#define REDLED 9
#define BLUELED 10
#define GREENLED 11
#define POT1 A0
int i = 0; // We’ll use this to count up and down
int brt = 0; // pot value
void setup() {
pinMode(REDLED, OUTPUT); // tell Arduino LED is an output
pinMode(BLUELED, OUTPUT); // tell Arduino LED is an output
pinMode(GREENLED, OUTPUT); // tell Arduino LED is an output
pinMode(POT1, INPUT); // tell Arduino LED is an output
}
void loop(){
brt = analogRead(POT1);
analogWrite(BLUELED, brt/5); // set the LED brightness
analogWrite(GREENLED, brt/5); // set the LED brightness
}
No comments:
Post a Comment