Hardware components | ||||||
![]() |
| × | 1 | |||
![]() |
| × | 3 | |||
![]() |
| × | 1 | |||
![]() |
| × | 1 | |||
Software apps and online services | ||||||
![]() |
| |||||
Hand tools and fabrication machines | ||||||
![]() |
|
int R = A3; //pin for red LED
int G = A4; //pin for green LED
int B = A5; //pin for blue LED
int potenciometar1= A2; //pin for first potentiometer
int potenciometar2= A1; //pin for second potentiometer
int potenciometar3= A0; //pin for third potentiometer
void setup()
{
pinMode(R, OUTPUT);
pinMode(G, OUTPUT);
pinMode(B, OUTPUT);
pinMode(potenciometar1, INPUT);
pinMode(potenciometar2, INPUT);
pinMode(potenciometar3, INPUT);
}
void loop(){
int x=analogRead(potenciometar1);
int y=analogRead(potenciometar2);
int z=analogRead(potenciometar3);
if(x<10 && y<10 && z<10)
BOJA(0,0,0);
else if(x>200 && y<10 && z<10)
BOJA(255,0,0);
else if(x<10 && y>200 && z<10)
BOJA(0,255,0);
else if(x<10 && y<10 && z>200)
BOJA(0,0,255);
else if(x>200 && y>200 && z<10)
BOJA(255,255,0);
else if(x>200 && y<10 && z>200)
BOJA(255,0,255);
else if(x<10 && y>200 && z>200)
BOJA(0,255,255);
else if(x>200 && y>200 && z<200)
BOJA(255,255,255);
}
/*
* function BOJA(color)
*/
void BOJA(int R_RED, int G_GREEN, int B_BLUE)
{
analogWrite(R, R_RED);
analogWrite(G, G_GREEN);
analogWrite(B, B_BLUE);
}
int R = A3; //pin for red LED
int G = A4; //pin for green LED
int B = A5; //pin for blue LED
int potenciometar1= A2; //pin for first potentiometer
int potenciometar2= A1; //pin for second potentiometer
int potenciometar3= A0; //pin for third potentiometer
void setup()
{
pinMode(R, OUTPUT);
pinMode(G, OUTPUT);
pinMode(B, OUTPUT);
pinMode(potenciometar1, INPUT);
pinMode(potenciometar2, INPUT);
pinMode(potenciometar3, INPUT);
}
void loop(){
int x=analogRead(potenciometar1);
int y=analogRead(potenciometar2);
int z=analogRead(potenciometar3);
if(x<10 && y<10 && z<10)
BOJA(0,0,0);
else if(x>200 && y<10 && z<10)
BOJA(255,0,0);
else if(x<10 && y>200 && z<10)
BOJA(0,255,0);
else if(x<10 && y<10 && z>200)
BOJA(0,0,255);
else if(x>200 && y>200 && z<10)
BOJA(255,255,0);
else if(x>200 && y<10 && z>200)
BOJA(255,0,255);
else if(x<10 && y>200 && z>200)
BOJA(0,255,255);
else if(x>200 && y>200 && z<200)
BOJA(255,255,255);
}
/*
* function BOJA(color)
*/
void BOJA(int R_RED, int G_GREEN, int B_BLUE)
{
analogWrite(R, R_RED);
analogWrite(G, G_GREEN);
analogWrite(B, B_BLUE);
}
Comments
Please log in or sign up to comment.