Cole 3 Potentiometer Fade

Posted by Cole

Cole's picture

 

I did the option with 3 pots, each controlling the brightness of an LED. The code is below.
 
int potPini = 2;   // select the input pin for the potentiometer
int ledPini = 9;   // select the pin for the LED
int potPinj = 1;   // select the input pin for the potentiometer
int ledPinj = 10;   // select the pin for the LED
int potPink = 0;   // select the input pin for the potentiometer
int ledPink = 11;   // select the pin for the LED
int vali = 0;      // variable to store the value coming from the sensor
int valj = 0;  //variable to store the value coming from the sensor
int valk = 0;  //variable to store the value coming from the sensor
void setup() {
  Serial.begin(9600);
}
void loop() {
  vali = analogRead(potPini);    // read the value from the sensor, between 0 - 1024
  valj = analogRead(potPinj);    // read the value from the sensor, between 0 - 1024
  valk = analogRead(potPink);    // read the value from the sensor, between 0 - 1024
  Serial.println(vali);
  Serial.println(valj);
  Serial.println(valk);
  analogWrite(ledPini, vali/4); // analogWrite can be between 0-255
  analogWrite(ledPinj, valj/4); // analogWrite can be between 0-255
  analogWrite(ledPink, valk/4); // analogWrite can be between 0-255
  
}
tripple potentiometer
0
Your rating: None
Tags: