This is a DIY Potentiometer that requires no tools to assemble.
Parts List:
- 3D Printed Knob
- 3D Printed Main Body
- 3D Printed Snap On Wire Holder
- A piece of printer paper
- Double sided tape
- A #2 pencil
- 3 Wires (Ideally something flexible like silicon)
Download the 3D files (STL) attached.
See the video here:
With a #2 pencil scribble a stripe 10mm or wider the across the width of a sheet of paper. Make sure it's on a smooth surface. Go back over it a couple of times making sure it is coated well in graphite. Don't leave any gaps.
On the other side of the stripe add double sided tape and cut an even strip 6mm wide.
Carefully add this strip on the inside edge of the main body.
Make sure to feed the wiper wire through the hole in the shaft, then through the hole between the other two wires...
This is the code I used for the potentiometer test...
Arduino Code:
/*
* Potentiometer Tester with Calibration Feature
* Creator: Chad Kapper from HackMakeMod Inc.
* For ESP8266
* This sketch is designed to test potentiometers, using a button to set the low and high calibration points.
* It visualizes the potentiometer's value on a strip of WS2812 LEDs. Pressing the button at a low value sets the lower limit,
* and pressing it at a high value sets the upper limit of the potentiometer's range. The LEDs light up based on the
* potentiometer's current position within the calibrated range.
*/
#include <FastLED.h>
// Pin definitions
#define POT_PIN A0 // Analog pin for potentiometer
#define BUTTON_PIN D1 // Button pin for calibration
#define LED_PIN D0 // Digital pin to control the LED strip
#define LED_COUNT 20 // Number of LEDs in the strip
#define THRESHOLD 5 // Minimum change in potentiometer value to update LEDs
CRGB leds[LED_COUNT]; // Array to store the LED colors
int prevValue = 0; // Stores the previous potentiometer value for comparison
int highValue = 1023; // Initial high calibration value (max value of potentiometer)
int lowValue = 0; // Initial low calibration value (min value of potentiometer)
void setup() {
Serial.begin(115200);
pinMode(BUTTON_PIN, INPUT_PULLUP); // Initialize the button as an input with an internal pull-up resistor
FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, LED_COUNT); // Initialize the LED strip
FastLED.setBrightness(30); // Set a moderate brightness level
FastLED.show(); // Ensure all LEDs are off initially
Serial.println("Setup complete, awaiting button press...");
}
void loop() {
int potValue = analogRead(POT_PIN); // Read the current value of the potentiometer
Serial.print("Potentiometer Value: ");
Serial.println(potValue);
// Check if the button is pressed (logic LOW if using INPUT_PULLUP)
if(digitalRead(BUTTON_PIN) == LOW) {
Serial.println("Button pressed");
// Calibrate the low or high value based on the current potentiometer reading
if(potValue < 300) { // Threshold to differentiate between low and high calibration
lowValue = potValue;
Serial.print("New lowValue: ");
Serial.println(lowValue);
} else {
highValue = potValue;
Serial.print("New highValue: ");
Serial.println(highValue);
}
potValue = 0; // Reset potValue to avoid immediate recalibration effect
FastLED.show(); // Update LED strip to reflect any changes
}
// Update LEDs only if the change in potentiometer value exceeds the threshold
if(abs(potValue - prevValue) >= THRESHOLD) {
prevValue = potValue; // Update previous value for next comparison
int numLEDS = map(potValue, lowValue, highValue, 0, LED_COUNT); // Map pot value to number of LEDs
// Create a color gradient based on the current position within the calibrated range
for(int i = 0; i < LED_COUNT; i++) {
int red = i * (255 / LED_COUNT);
int green = 255 - red;
if(i < numLEDS) {
leds[i] = CRGB(red, green, 0); // Set color based on position
} else {
leds[i] = CRGB::Black; // Turn off LEDs beyond the current position
}
}
FastLED.show(); // Update the LED strip with new colors
}
delay(30); // Short delay to debounce button and slow down the loop for readability
}