Circuit Diagram
Components
1 x 10 k Potentiometer
2 x Led
Wires
Code
int sensorPin = 0; // The potentiometer is connected to
// analog pin 0
int ledPin = 12;
int ledPin2 = 13; // The LED is connected to digital pin 13
void setup() // this function runs once when the sketch starts up
{
pinMode(ledPin, OUTPUT);
pinMode(ledPin2, OUTPUT);
}
void loop() // this function runs repeatedly after setup() finishes
{
int sensorValue;
sensorValue = analogRead(sensorPin);
digitalWrite(ledPin, HIGH); // Turn the LED on
delay(sensorValue); // Pause for sensorValue
digitalWrite(ledPin, LOW); // Turn the LED off
delay(sensorValue);
digitalWrite(ledPin2, HIGH);
delay(1/sensorValue);
// milliseconds
// Pause for sensorValue
// milliseconds
digitalWrite(ledPin2, LOW); // Turn the LED off
delay(1/sensorValue);
}
Video
Hiç yorum yok:
Yorum Gönder