#define ledR 25
#define ledG 26
#define ledB 27
#define vrPin 35 // CHANGE to 36 BEFORE TEST
void setup() {
Serial.begin(115200); //speed-bps (Bits per second.)
pinMode(ledR, OUTPUT);
pinMode(ledG, OUTPUT);
pinMode(ledB, OUTPUT);
digitalWrite(ledR, 1);
digitalWrite(ledG, 1);
digitalWrite(ledB, 1);
}
void loop() {
int vrMap = map(analogRead(vrPin), 0, 4095, 0, 1000); // (12-bit) , 0-4095 to 0-1000
Serial.println("VR value : " + String(vrMap));
if(vrMap >= 0){
digitalWrite(ledR, 0);
digitalWrite(ledG, 1);
digitalWrite(ledB, 1);
if (vrMap >= 143){
digitalWrite(ledG, 0);
digitalWrite(ledB, 1);
if(vrMap >= 286){
digitalWrite(ledG, 0);
digitalWrite(ledR, 1);
digitalWrite(ledB, 1);
if(vrMap >= 429){
digitalWrite(ledB, 0);
digitalWrite(ledR, 1);
if(vrMap >= 572){
digitalWrite(ledB, 0);
digitalWrite(ledR, 1);
digitalWrite(ledG, 1);
if(vrMap >= 715){
digitalWrite(ledR, 0);
digitalWrite(ledB, 0);
digitalWrite(ledG, 1);
if(vrMap >= 858){
digitalWrite(ledR, 0);
digitalWrite(ledB, 0);
digitalWrite(ledG, 0);
}
}
}
}
}
}
}
delay(50);
}