//potentiometer reading (v)
int testPin = A0;
int pinDim = 3;
int redPin = 7;
int testValue;
float dimLed;
float V2;
void setup() {
// put your setup code here, to run once:
pinMode(testPin, INPUT);
pinMode(13, OUTPUT);
pinMode(pinDim, OUTPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
testValue = analogRead(testPin);
V2 = (5./1023.)*testValue;
Serial.println(V2);
dimLed = (255./1023.)*testPin;
if(V2>4.0)
{
digitalWrite(redPin, HIGH);
}
else
{digitalWrite(redPin, LOW);}
analogWrite(pinDim,dimLed);
delay(250);
}