X9C103S is a light Arduino library to control X9C103S digital potentiometers. This library allows you to easily set, increase, and decrease the resistance of the X9C103S potentiometer.
- Open the Arduino IDE.
- Go to
Sketch
>Include Library
>Manage Libraries...
. - In the Library Manager, search for
X9C103S
. - Click on the
X9C103S
library entry and pressInstall
.
- Download the latest release from the GitHub releases page.
- Extract the downloaded ZIP file.
- Go to Arduino IDE
- Click on 'Sketch'
- Click on 'Include Library'
- Click on 'Add .ZIP Library...'
- Browse to the location of the zip file
- Click on the zip file
- Download the latest release from the GitHub releases page.
- Extract the downloaded ZIP file.
- Move the extracted folder to your Arduino libraries directory (
~/Documents/Arduino/libraries
on Windows and macOS,~/Arduino/libraries
on Linux).
The library comes with several example sketches to help you get started. You can find these in the examples
folder. Here are a few examples with brief descriptions and code snippets.:
This example demonstrates how to initialize the potentiometer and read its resistance.
#include <X9C103S.h>
void setup() {
Serial.begin(9600);
X9C103S pot1(6, 7, 8) //X9C103S digital potentiometer connected with inc pin to pin 6 ud pin to pin 7 and cs pin to pin 8. Change pin numbers as nessary.
pot1.initializePot()
}
void loop() {
pot1.setResistance(45) //Sets the pot resistance to 50. The number can be any number from 1 to 100 (both included).
pot1.increaseResistance(25) //Increases the pot resistance by 10. The resistance is now at the value 70.
Serial.write(pot1.getResistance()) //Gets the resistanceof the pot and sends it via serial.
}
This example demonstrates how to set the potentiometer to its highest value easily.
#include <X9C103S.h>
void setup() {
Serial.begin(9600);
X9C103S pot1(6, 7, 8) //X9C103S digital potentiometer connected with inc pin to pin 6 ud pin to pin 7 and cs pin to pin 8. Change pin numbers as nessary.
pot1.initializePot()
}
void loop() {
pot1.setResistance(45) //Sets the pot resistance to 50. The number can be any number from 1 to 100 (both included).
pot1.setToHighest() //Sets the pot resistance to highest value(100).
Serial.write(pot1.getResistance()) //Gets the resistanceof the pot and sends it via serial(Should be 100).
}