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.
Now upload the following Arduino sketch:
- Connect the LED to the D1/D2 Digital I/O jack, like it was in Projects 1 and 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.
- Connect the Potentiometer to the Analog A0/A1 input jack.
- The Potentiometer produces an analog voltage on its D1 output, which is connected to Arduino A0 analog input on the A0/A1 input jack.
// Project Three - Analog Input
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 (www.seeedstudio.com
This static html page was created from http://www.seeedstudio.com/wiki