0% found this document useful (0 votes)
4 views2 pages

Const Int R

The document contains an Arduino sketch that sets up and controls multiple output pins for different colors. It reads an analog value from a potentiometer and uses that value to determine which color to display by turning on specific output pins. The program continuously loops to adjust the displayed color based on the potentiometer's position.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Const Int R

The document contains an Arduino sketch that sets up and controls multiple output pins for different colors. It reads an analog value from a potentiometer and uses that value to determine which color to display by turning on specific output pins. The program continuously loops to adjust the displayed color based on the potentiometer's position.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

const int R = 2;

const int G = 3;
const int B = 4;
const int Y = 5;
const int W = 6;
const int P = 9;
const int O = 10;
const int T = 11;
const int F = 12;
const int H = 13;
const int POT = A1;

void setup() {
// put your setup code here, to run once:
pinMode(R, OUTPUT);
pinMode(G, OUTPUT);
pinMode(B, OUTPUT);
pinMode(Y, OUTPUT);
pinMode(W, OUTPUT);
pinMode(P, OUTPUT);
pinMode(O, OUTPUT);
pinMode(T, OUTPUT);
pinMode(F, OUTPUT);
pinMode(H, OUTPUT);
}

void show(int r, int g, int b, int y, int w, int p, int o, int t, int f, int h){
digitalWrite(R, r);
digitalWrite(G, g);
digitalWrite(B, b);
digitalWrite(Y, y);
digitalWrite(W, w);
digitalWrite(P, p);
digitalWrite(O, o);
digitalWrite(T, t);
digitalWrite(F, f);
digitalWrite(H, h);
}

void loop() {
// put your main code here, to run repeatedly:
int v = analogRead(POT);
if (v < 93){
show(HIGH, LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW);
}else if (v < 186){
show(LOW, HIGH, LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW);
}else if (v < 279){
show(LOW, LOW, HIGH, LOW, LOW, LOW, LOW, LOW, LOW, LOW);
}else if (v < 372){
show(LOW, LOW, LOW, HIGH, LOW, LOW, LOW, LOW, LOW, LOW);
}else if (v < 465){
show(LOW, LOW, LOW, LOW, HIGH, LOW, LOW, LOW, LOW, LOW);
}else if (v < 558){
show(LOW, LOW, LOW, LOW, LOW, HIGH, LOW, LOW, LOW, LOW);
}else if (v < 651){
show(LOW, LOW, LOW, LOW, LOW, LOW, HIGH, LOW, LOW, LOW);
}else if (v < 744){
show(LOW, LOW, LOW, LOW, LOW, LOW, LOW, HIGH, LOW, LOW);
}else if (v < 837){
show(LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW, HIGH, LOW);
}else if (v < 930){
show(LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW, HIGH);
}else {
show(HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH);
}
}

You might also like