Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
782 B
1
Indexable
Never
const int potPin= A0;
const int LEDPin= 9;
const int LEDPin1=10;
const int LEDPin2=11;
int readValue;
float writeValue;
void setup() {
 pinMode(LEDPin, OUTPUT);
 pinMode(LEDPin1, OUTPUT);
 pinMode(LEDPin2, OUTPUT);
  Serial.begin(9600);
}
void loop() {
readValue = analogRead(potPin);
 writeValue = (255.0/1023.0)*readValue;
 if(writeValue <=83.0){
  analogWrite(LEDPin, writeValue);
 }
 if(writeValue >=83.0 && writeValue <= 166.0){
  analogWrite(LEDPin1, writeValue-83.0);
 }else if(writeValue < 83.0){
  analogWrite(LEDPin1, 0);
 }
 if(writeValue >=166.0 && writeValue <=255.0){
  analogWrite(LEDPin2, writeValue-166.0);
 }else if(writeValue < 166.0){
  analogWrite(LEDPin2, 0);
 }
 Serial.print("Writing a value of ");
Serial.println(writeValue);
}