[Assignment 3] Potentiometers
Description
I used three potentiometers as input value of each color; red, green, blue.
Components Used
- Arduino UNO
- 3* 220 Ohm Resistor, RGB LEDs
- Small Bottle, Wrinkled Paper
-
3 Potentiometers
Code
// Eungchan Kim
// 2013-02-19
int potPin[3] = {A0,A1,A2}; // select the input pin for the potentiometer
int ledPin[3] = {9,10,11}; // select the pin for the LED
int RGB[3] = {0,0,0};
int val = 0; // variable to store the value coming from the sensor
void setup() {
for (int i=0;i<3;i++){
pinMode(ledPin[i], OUTPUT); // declare the ledPin as an OUTPUT
}
}
void loop() {
for (int i=0;i<3;i++){
// read the value from the sensor and normalized ranged from 0 to 255
RGB[i] = analogRead(potPin[i])*0.25;
}
for (int i=0;i<3;i++){
analogWrite(ledPin[i], RGB[i]); // turn the ledPin on
}
delay(100); // stop the program for some time
}
Image
- Login to post comments
Drupal theme by Kiwi Themes.