hey guys
i'm pretty sure the problem is in the code ... no matter how simple it is I always find a way to make it not work with the setup....
here it is
int sensorPin = 1;
int ledPins[] = {0, 1, 2, 3, 4, 5, 6};
int val = 0;
void setup() {
pinMode(ledPins[0], OUTPUT);
pinMode(ledPins[1], OUTPUT);
pinMode(ledPins[2], OUTPUT);
pinMode(ledPins[3], OUTPUT);
pinMode(ledPins[4], OUTPUT);
pinMode(ledPins[5], OUTPUT);
pinMode(ledPins[6], OUTPUT);
Serial.begin(9600);
}
void loop()
{
val = analogRead(sensorPin);
val = map(val, 0, 1023, 0, 1200);
{ while (val>=0 && val <=200 )
digitalWrite(ledPins[0,1], HIGH);}
{while (val>=201 && val <=400 )
digitalWrite(ledPins[2,3], HIGH); }
{while (val>=401 && val <=600 )
digitalWrite(ledPins[4,5,6], HIGH);}
Serial.println(val);
}
overview of the led's on their coresponing pins-
0,1 - blue ;
2,3 - red;
4,5,6 - green; (had a extra green one lol)
so the basic idea is to read the Pot pin - analog0, then map it out for 1200 value (from 1024). Then according to it , on intervals of 200, light up the different color led's and turn the other clrs off, that leaves 3 more intervals of 200 each for mixing colors or 6 ints if they are 100 each.
why aren't any of them lighting up? NONE of them turn on and the serial read on the pot pin reads >nothing<, and i'm pretty sure it's connected properly. it might be the "while" functions ... i thought of using "if"-s but ... idk, it felt weird to use it.
any suggestions ... or overall help would be awesome