LinkIt ONE Tutorial - Analog Interface

Introduction

What We’re Doing
In the previous sections, we learned how to control the circuit’s input and output using digital interface. In this section, we will learn how to vary the output using an analog device called a potentiometer (also known as a variable resistor). A potentiometer is used to vary the voltage in the range of 0 ~ 5V. The MPU reads the voltage value in the range of 0-1023.This can be used to control the brightness of the LED (PWM simulation output interface). If the potentiometer is turned clockwise, the LED brightens gradually. If it is rotated anticlockwise, the luminosity fades.
Things you need
  • LinkIt One x 1
  • Break board x 1
  • Resistors 330Ω,10kΩ,1kΩ x 1
  • 5mm LED x 1
  • Slide Potentiometer 10kΩ x 1
  • Transistor(2N3904) x 1
Schematic
Connection
Code
Please click on the button below to download the code for the kit:
You can unzip the file to the Examples folder of your Arduino IDE.
To access the demo code open:
File -> Examples -> Starter Kit for LinkIt -> Basic -> L6_Analog_Ctrl_LED
const int led = 3; const int pot = A0; void setup() { // nothing to initialize } void loop() { int val = analogRead(pot); // get value from potentiometer val = map(val, 0, 1023, 0, 255); // make the value to 0~255 analogWrite(led, val); // set the pwm of led delay(10); }
Troubleshooting
  • Pin Interfacing problem?
    • If you have connected the input to digital pin instead of analog pin the circuit might not work properly.
  • Not Working?
    • Potentiometer has three pins in it . Check whether you have connected the middle pin to the analog interface or else the circuit might not work properly.
Making it better
To control flickering frequency of the LED with a potentiometer upload the following code To Open the demo code:
To open the demo code:
File -> Examples -> Starter Kit for LinkIt -> Extend_Lesson –> L6_Flashing_LED
More ideas
What else can do with the Potentiometer of the return value?
Reference

Help us make it better

Thank you for choosing Seeed. A couple of months ago we initiated a project to improve our documentation system. What you are looking at now is the first edition of the new documentation system. Comparing to the old one, here is the progresses that we made:
  • Replaced the old documentation system with a new one that was developed from Mkdocs, a more widely used and cooler tool to develop documentation system.
  • Integrated the documentation system with our official website, now you can go to Bazaar and other section like Forum and Community more conveniently.
  • Reviewed and rewrote documents for hundreds of products for the system’s first edition, and will continue migrate documents from old wiki to the new one.
An easy-to-use instruction is as important as the product itself. We are expecting this new system will improve your experience when using Seeed’s products. However since this is the first edition, there are still many things need to improve, if you have any suggestions or findings, you are most welcome to submit the amended version as our contributor or give us suggestions in the survey below, Please don’t forget to leave your email address so that we can reply.
Happy hacking