In this lesson, you will rewrite Blink code. However, your delay function change according to your analog value. To do this lesson, you need a 10k potentiometer. The potentiometer will be connected to the ESPcopter’ analog pin which is 2. You can find out this pin by using ESPcopter’ pin out diagram.


Analog Input


int sensorPin = A0; // select the input pin for the potentiometer
 int ledPin = 10; // select the pin for the LED
 int sensorValue = 0; // variable to store the value coming from the sensor

void setup() {
 // declare the ledPin as an OUTPUT:
 pinMode(ledPin, OUTPUT);

void loop() {
 // read the value from the sensor:
 sensorValue = analogRead(sensorPin);
 // turn the ledPin on
 digitalWrite(ledPin, HIGH);
 // stop the program for <sensorValue> milliseconds:
 // turn the ledPin off:
 digitalWrite(ledPin, LOW);
 // stop the program for for <sensorValue> milliseconds: