This is the sliding Potentiometer that provides intuitive benefits in to control and adjusting a resistance. For example controlling UP and DOWN, FORWARD and REVERSE, LEFT and RIGHT sometimes using Rotary Potentiometer is confusing. Slider potentiometer has a logarithmic taper from the center position the further you move from center the less the change in resistance per inch or mm. Logarithmic potentiometer are mostly used in AUDIO CONTROL, MOTOR CONTROL. As you can see the diagram below its uses 4 potentiometer connected to Analog Pin, which you can control the output via i2C (Serial Communication) ether controlling a i2C Analog to Digital Converter, LCD Screens, i2C Motor Controller, and i2C Servo Controller. Etc.
Required Component
- Arduino Microcontroller, ATTINY, STM32, AVR, ESP8266, Teensy, PINDUINO
- Sliding Potentiometer (10k / 5k)
- LED (5mm / 3mm)
- Resistor (220 Ohms)
- Solder Less Bread Board
- Jumper Wire / DuPont Wire
Wiring Diagram
Source Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
const int sP1 = A0, sP2 = A1, sP3 = A2, sP4 = A3; int RawVal1 = 0, RawVal2 = 0, RawVal3 = 0, RawVal4 = 0, onDelay = 500; float vVal1= 0, vVal2 = 0, vVal3 = 0, vVal4 = 0; float res1 = 0, res2 = 0, res3 = 0, res4 = 0; void setup() { Serial.begin(9600); pinMode(sP1, INPUT); pinMode(sP2, INPUT); pinMode(sP3, INPUT); pinMode(sP4, INPUT); Serial.println("14CORE | Sliding Potensiometer Test Code"); Serial.println("========================================"); } void loop() { RawVal1 = analogRead(sP1); RawVal2 = analogRead(sP2); RawVal3 = analogRead(sP3); RawVal4 = analogRead(sP4); vVal1 = (RawVal1 * 5.0) / 1024.0; vVal2 = (RawVal2 * 5.0) / 1024.0; vVal3 = (RawVal3 * 5.0) / 1024.0; vVal4 = (RawVal4 * 5.0) / 1024.0; res1 = 5000.0 * (RawVal1/2024.0); res2 = 5000.0 * (RawVal2/2024.0); res3 = 5000.0 * (RawVal3/2024.0); res4 = 5000.0 * (RawVal4/2024.0); Serial.print("Raw Value 1 = "); Serial.print(RawVal1); Serial.print("\t Voltage 1 = "); Serial.print(vVal1); Serial.print("\t Resistance 1 = "); Serial.print(res1); Serial.print("Raw Value 2 = "); Serial.print(RawVal1); Serial.print("\t Voltage 2 = "); Serial.print(vVal1); Serial.print("\t Resistance 2 = "); Serial.print(res1); Serial.print("Raw Value 3 = "); Serial.print(RawVal1); Serial.print("\t Voltage 3 = "); Serial.print(vVal1); Serial.print("\t Resistance 3 = "); Serial.print(res1); Serial.print("Raw Value 4 = "); Serial.print(RawVal1); Serial.print("\t Voltage 4 = "); Serial.print(vVal1); Serial.print("\t Resistance 4 = "); Serial.print(res1); delay(onDelay); } |
Source Code on Arrays
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
/* www.14core.com */ const int val [] = {A0, A1, A2, A3}; //Analog in Array float vVal [] = {0, 5000.0}; //Floating variable in array int rawval[] = {0,3000}; //Integer variable in array void setup() { Serial.begin(9600); //Start serial at baud rate 9600 pinMode(val[0], INPUT); //Set val A0 as INPUT pinMode(val[1], INPUT); //Set val A1 as INPUT pinMode(val[2], INPUT); //Set val A2 as INPUT pinMode(val[3], INPUT); //Set val A3 as INPUT Serial.println(" 14CORE | Sliding Potensiometer Test Code"); Serial.println("========================================"); } void loop() { Serial.println("---------------------------------"); Serial.print("\t | Raw Value A0:"); Serial.println(analogRead(val[0])); //Get Raw value of Analog IN (A0) Serial.print("\t | Voltage : "); Serial.println(analogRead(val[0] * 5.0) / 1024.0); //Get Raw Value x 5.0 / 1024 Voltage Serial.print("\t | Resistance : "); Serial.println(analogRead(val[0] * vVal[1] / 1024.0)); //Get Raw Value x 5000 / 1024 Serial.println("================================="); Serial.print("\t | Raw Value A1:"); Serial.println(analogRead(val[1])); Serial.print("\t | Voltage : "); Serial.println(analogRead(val[1] * 5.0) / 1024.0); Serial.print("\t | Resistance : "); Serial.println(analogRead(val[1] * vVal[1] / 1024.0)); Serial.println("---------------------------------"); Serial.print("\t | Raw Value A2:"); Serial.println(analogRead(val[2])); Serial.print("\t | Voltage : "); Serial.println(analogRead(val[2] * 5.0) / 1024.0); Serial.print("\t | Resistance : "); Serial.println(analogRead(val[2] * vVal[1] / 1024.0)); Serial.println("=================================="); Serial.print("\t | Raw Value A3:"); Serial.println(analogRead(val[3])); Serial.print("\t | Voltage : "); Serial.println(analogRead(val[3] * 5.0) / 1024.0); Serial.print("\t | Resistance : "); Serial.println(analogRead(val[3] * vVal[1] / 1024.0)); Serial.println("---------------------------------"); delay(rawval[1]); } |