Hey i am a noob. Trying to get one led to blink fast whilst a second led to blink slow and when i turn the potentiometer the fast one will slow and the slow one will increase in speed.
Have Arduino Uno so i can't use the Scheduler.
Here is my code thus far. No errors but not doing what i would like it to.
int sensorPin = 0; // The potentiometer is connected to
// analog pin 0
int ledPin = 13; // The LED is connected to digital pin 13
int ledPin2 = 12; // The LED is connected to digital pin 12
int sensorValue;
void setup()
{
pinMode(ledPin, OUTPUT);
pinMode(ledPin2, OUTPUT);
}
void loop() // this function runs repeatedly after setup() finishes
{
lights1();
lights2();
}
void lights1(){
sensorValue = analogRead(sensorPin);
digitalWrite(ledPin, HIGH); // Turn the LED on
delay(sensorValue); // Pause for sensorValue
digitalWrite(ledPin, LOW); // Turn the LED off
delay(sensorValue); // Pause for sensorValue
}
void lights2(){
int newSensorValue;
newSensorValue = map(sensorValue, 0, 1023, 1023, 0);
sensorValue = analogRead(sensorPin);
digitalWrite(ledPin2, HIGH); // Turn the LED on
delay(newSensorValue); // Pause for sensorValue
digitalWrite(ledPin2, LOW); // Turn the LED off
delay(newSensorValue); // Pause for sensorValue
}