Slide Potentiometer Module

아두위키 : Arduwiki

It's a component capable of varying resistance values. It can be used for adjusting volume or the brightness of light.

Specifications

  • Recommended Input Voltage: 3.3V ~ 5V
  • Two analog output pins (output values are the same for both pins)
  • 10Kohm

Example Required Hardware

  • Arduino board
  • Jumper cables
  • Slide potentiometer module
  • LCD1602

Connection

Arduino Slide Potentiometer Module LCD
5V VCC, VCC VCC
GND GND, GND GND
A4 SDA
A5 SCL
A6 OTB
A7 OTA

Example Code

This example demonstrates how to display the values from the slide potentiometer on an LCD screen.

Please refer to the link for instructions on using the LCD.

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);

const int otb = A6;
const int ota = A7;
int val1 = 0;
int val2 = 0;

void setup() {
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("OTA:");
  lcd.setCursor(0, 1);
  lcd.print("OTB:");
}

void loop() {
  if (val1 != analogRead(ota)) {
    val1 = analogRead(ota);
    for (int i = 4; i < 8; i++) {
      lcd.setCursor(i, 0);
      lcd.print("    ");
    }
    lcd.setCursor(4, 0);
    lcd.print(val1);
  }

  if (val2 != analogRead(otb)) {
    val2 = analogRead(otb);
    for (int i = 4; i < 8; i++) {
      lcd.setCursor(i, 1);
      lcd.print("    ");
    }
    lcd.setCursor(4, 1);
    lcd.print(val2);
  }
  delay(300);
}

Execution Result