#define LedGreen 9
#define LedRed 10
int pot=A0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(LedGreen, OUTPUT);
pinMode(LedRed, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int ValueCompare=0;
int PotValue=0;
int BrightValue=0;
int SecondaryBrightValue=0;
PotValue=analogRead(pot);
BrightValue=map(PotValue,0,1023,512,0);
ValueCompare=512;
if(PotValue>=ValueCompare){
SecondaryBrightValue=map(PotValue,0,1023,0,512);
analogWrite(LedRed,LOW);
analogWrite(LedGreen,SecondaryBrightValue);
}
else{
analogWrite(LedRed,BrightValue);
analogWrite(LedGreen,LOW);
}
Serial.print("RedBrightness=");
Serial.print(BrightValue);
Serial.print(" GreenBrightness=");
Serial.print(SecondaryBrightValue);
Serial.print(" RawPotValue=");
Serial.println(PotValue);
}