Project Three – Analog Input

The purpose of this sketch is to demonstrate a form of analog input using the potentiometer . We will use this to set the delay for our blinking LEDs from project one.

Wiring it:

  1. Connect the LED to the D1/D2 Digital I/O jack, like it was in Projects 1 and 2.
  2. Arduino Pin D1 powers the Red LED on the Grove's D1 connector, and Arduino Pin D2 powers the Green LED on the Grove's D2 connector.
  3. Connect the Potentiometer to the Analog A0/A1 input jack.
  4. The Potentiometer produces an analog voltage on its D1 output, which is connected to Arduino A0 analog input on the A0/A1 input jack.

Now upload the following Arduino sketch:
// Project Three - Analog Input

void setup()
  pinMode(1, OUTPUT);
  pinMode(2, OUTPUT);

void loop()
  digitalWrite(1, HIGH);
  digitalWrite(2, LOW);  
  digitalWrite(1, LOW);
  digitalWrite(2, HIGH);  

The maximum delay value is 1023, as this is the upper limit of the value returned by the analogRead() function. You could use mathematical functions to increase or scale down the range of the delay. Copyright (c) 2008-2016 Seeed Development Limited ( /
This static html page was created from