# Graphite resistance mood light

The lights work by how much resistance is there and depending on how much resistance is there then certain lights turn on or off.

``````int sVal = 0;
int sPin = 0;
int ledPin5 = 10;
int ledPin4 = 9;
int ledPin3 = 6;
int ledPin2 = 5;
int ledPin1 = 3;
void setup() {
pinMode(sPin,INPUT);
pinMode(ledPin1,OUTPUT);
pinMode(ledPin2,OUTPUT);
pinMode(ledPin3,OUTPUT);
pinMode(ledPin4,OUTPUT);
pinMode(ledPin5,OUTPUT);
Serial.begin(9600);
}

void loop() {
Serial.print(sVal);
Serial.print(", ");
sVal = map(sVal, 0, 170, 0, 5);

if(sVal==1){
digitalWrite(ledPin1,HIGH);
digitalWrite(ledPin2,LOW);
digitalWrite(ledPin3,LOW);
digitalWrite(ledPin4,LOW);
digitalWrite(ledPin5,LOW);
}else if(sVal==2){
digitalWrite(ledPin1,HIGH);
digitalWrite(ledPin2,HIGH);
digitalWrite(ledPin3,LOW);
digitalWrite(ledPin4,LOW);
digitalWrite(ledPin5,LOW);
}else if(sVal==3){
digitalWrite(ledPin1,HIGH);
digitalWrite(ledPin2,HIGH);
digitalWrite(ledPin3,HIGH);
digitalWrite(ledPin4,LOW);
digitalWrite(ledPin5,LOW);
}else if(sVal==4){
digitalWrite(ledPin1,HIGH);
digitalWrite(ledPin2,HIGH);
digitalWrite(ledPin3,HIGH);
digitalWrite(ledPin4,HIGH);
digitalWrite(ledPin5,LOW);
}else if(sVal>=5){
digitalWrite(ledPin1,HIGH);
digitalWrite(ledPin2,HIGH);
digitalWrite(ledPin3,HIGH);
digitalWrite(ledPin4,HIGH);
digitalWrite(ledPin5,HIGH);
} else if(sVal < 1){
digitalWrite(ledPin1,LOW);
digitalWrite(ledPin2,LOW);
digitalWrite(ledPin3,LOW);
digitalWrite(ledPin4,LOW);
digitalWrite(ledPin5,LOW);
}

Serial.println(sVal);
}
``````

This block of code:

``````   if(sVal==1){
digitalWrite(ledPin1,HIGH);
digitalWrite(ledPin2,LOW);
digitalWrite(ledPin3,LOW);
digitalWrite(ledPin4,LOW);
digitalWrite(ledPin5,LOW);
}else if(sVal==2){
digitalWrite(ledPin1,HIGH);
digitalWrite(ledPin2,HIGH);
digitalWrite(ledPin3,LOW);
digitalWrite(ledPin4,LOW);
digitalWrite(ledPin5,LOW);
}else if(sVal==3){
digitalWrite(ledPin1,HIGH);
digitalWrite(ledPin2,HIGH);
digitalWrite(ledPin3,HIGH);
digitalWrite(ledPin4,LOW);
digitalWrite(ledPin5,LOW);
}else if(sVal==4){
digitalWrite(ledPin1,HIGH);
digitalWrite(ledPin2,HIGH);
digitalWrite(ledPin3,HIGH);
digitalWrite(ledPin4,HIGH);
digitalWrite(ledPin5,LOW);
}else if(sVal>=5){
digitalWrite(ledPin1,HIGH);
digitalWrite(ledPin2,HIGH);
digitalWrite(ledPin3,HIGH);
digitalWrite(ledPin4,HIGH);
digitalWrite(ledPin5,HIGH);
} else if(sVal < 1){
digitalWrite(ledPin1,LOW);
digitalWrite(ledPin2,LOW);
digitalWrite(ledPin3,LOW);
digitalWrite(ledPin4,LOW);
digitalWrite(ledPin5,LOW);
}
``````

can be replaced by this block of code:

``````    digitalWrite(ledPin1,sVal>=1);
digitalWrite(ledPin2,sVal>=2);
digitalWrite(ledPin3,sVal>=3);
digitalWrite(ledPin4,sVal>=4);
digitalWrite(ledPin5,sVal>=5);
``````