Potentiometer ECE4180L4
Simple Potentiometer Demo for mbed
Hello World
Import programECE4180L4_Pot
"Hello World" program for using potentiometers with mBed. ECE4180 Lab 4.
Library
Import programECE4180L4_Pot
"Hello World" program for using potentiometers with mBed. ECE4180 Lab 4.
Notes
Potentiometer Basics
In the world of electronics, potentiometers are informally referred to as pots. The most common type of pots are three-terminal resistors with an electrical contact that either slides or rotates along a resistor (or in some cases between different resistors) in a voltage divider circuit to provide variable resistance (and variable voltage output).
These simple pots include three leads - the outer two should be connected to 3.3v and gnd (the Vout and Gnd pins on the mBed) and the inner lead should be connected to p20 (an analog input).
Here is another quick demo idea with less parts to hook up. The analog input from the pot, dims the LED using PWM. It is easy since both AnalogIn and PwmOut are scaled from 0.0 to1.0 .
#include "mbed.h" PwmOut myled(LED1); AnalogIn mypotentiometer(p20); int main() { while(1) { myled = mypotentiometer; wait(0.01); } }
Sparkfun's small 10K pot will plug directly in a breadboard. The spacing on the 3 inline leads lines up well. The knob is also just large enough to turn without using a screwdriver.
You need to log in to post a discussion