Slide Potentiometer Module

아두위키 : Arduwiki
ArduWiki (토론 | 기여)님의 2024년 3월 24일 (일) 16:33 판 (Created page with "{{#seo:|title=아두위키 : 아두이노 슬라이드 가변저항 가이드|title_mode=append|keywords=아두이노, 정보과학, 메이커학습, 수행평가, 슬라이드 가변저항, 아두이노 작품, 캡스톤작품, 아두이노 예제코드|description=아두이노로 슬라이드 가변저항을 제어하는 방법(기본정보, 회로, 예제 코드)을 소개합니다. 정보과학과 메이커수업에 활용가능합니다.}} File:슬라이드가변...")
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

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

For the operation video, please refer to the provided link.