#define R A0
#define G A1
#define B A2
#define me1 D0
#define me2 D1
#define me3 D2
#define you1 D3
#define you2 D4
#define you3 D5
#define pot1 A3
#define pot2 A4
#define RB A5
#define GB A6
#define BB A7
#define potRange 4094
int Red=0;
int Green=0;
int Blue=0;
int me=0;
int you=0;
void setup() {
pinMode(R, OUTPUT); pinMode(G, OUTPUT); pinMode(B, OUTPUT);
pinMode(me1, OUTPUT); pinMode(me2, OUTPUT); pinMode(me3, OUTPUT);
pinMode(you1, OUTPUT); pinMode(you2, OUTPUT); pinMode(you3, OUTPUT);
pinMode(pot1, INPUT);
pinMode(pot2, INPUT);
pinMode(RB,INPUT_PULLDOWN);
pinMode(GB,INPUT_PULLDOWN);
pinMode(BB,INPUT_PULLDOWN);
Spark.variable("me", &me, INT);
Spark.variable("you", &you, INT);
interrupts();
attachInterrupt(RB, redF, RISING);
attachInterrupt(GB, greenF, RISING);
attachInterrupt(BB, blueF, RISING);
}
void loop() {
me=analogRead(pot1);
you=analogRead(pot2);
if(me<=potRange/4) {digitalWrite(me1,LOW);digitalWrite(me2,LOW);digitalWrite(me3,LOW);}
if((me<=(2*potRange/4))&&(me>potRange/4)) {digitalWrite(me1,HIGH);digitalWrite(me2,LOW);digitalWrite(me3,LOW);}
if((me<=(3*potRange/4))&&(me>2*potRange/4)) {digitalWrite(me1,HIGH);digitalWrite(me2,HIGH);digitalWrite(me3,LOW);}
if(me>3*potRange/4) {digitalWrite(me1,HIGH);digitalWrite(me2,HIGH);digitalWrite(me3,HIGH);}
if(you<=potRange/4) {digitalWrite(you1,LOW);digitalWrite(you2,LOW);digitalWrite(you3,LOW);}
if((you<=(2*potRange/4))&&(you>potRange/4)) {digitalWrite(you1,HIGH);digitalWrite(you2,LOW);digitalWrite(you3,LOW);}
if((you<=(3*potRange/4))&&(you>2*potRange/4)) {digitalWrite(you1,HIGH);digitalWrite(you2,HIGH);digitalWrite(you3,LOW);}
if(you>3*potRange/4) {digitalWrite(you1,HIGH);digitalWrite(you2,HIGH);digitalWrite(you3,HIGH);}
}
void redF()
{
Red=!Red;
digitalWrite(R,Red?HIGH:LOW);
}
void greenF()
{
Green=!Green;
digitalWrite(G,Green?HIGH:LOW);
}
void blueF()
{
Blue=!Blue;
digitalWrite(B,Blue?HIGH:LOW);
}
Click to Expand
Content Rating
Is this a good/useful/informative piece of content to include in the project? Have your say!
You must login before you can post a comment. .