The Adafruit NeoSlider uses a seesaw chip. To use the NeoSlider with Arduino, you'll use the Adafruit Seesaw library. With the STEMMA QT connectors, you can easily get started with no soldering necessary!
I2C Wiring
Here is how to wire up the breakout using one of the STEMMA QT connectors. The examples show a Metro but wiring will work the same for an Arduino or other compatible board.
- Connect board VIN (red wire) to Arduino 5V if you are running a 5V board Arduino (Uno, etc.). If your board is 3V, connect to that instead.
- Connect board GND (black wire) to Arduino GND
- Connect board SCL (yellow wire) to Arduino SCL
- Connect board SDA (blue wire) to Arduino SDA
Here is how to wire the breakout to a board using a solderless breadboard. To do this, you must solder header pins to the breakout.
- Connect board VIN (red wire) to Arduino 5V if you are running a 5V board Arduino (Uno, etc.). If your board is 3V, connect to that instead.
- Connect board GND (black wire) to Arduino GND
- Connect board SCL (yellow wire) to Arduino SCL
- Connect board SDA (blue wire) to Arduino SDA
Library Installation
You can install the Adafruit Seesaw library for Arduino using the Library Manager in the Arduino IDE.
Click the Manage Libraries ... menu item, search for seesaw , and select the Adafruit seesaw library:
When asked to install the Adafruit Seesaw library dependencies, click Install all.
// SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries // SPDX-License-Identifier: MIT /* * This example shows how read the potentiometer on the I2C QT Slide Potentiometer * and make the NeoPixels change too! */ #include "Adafruit_seesaw.h" #include <seesaw_neopixel.h> #define DEFAULT_I2C_ADDR 0x30 #define ANALOGIN 18 #define NEOPIXELOUT 14 Adafruit_seesaw seesaw; seesaw_NeoPixel pixels = seesaw_NeoPixel(4, NEOPIXELOUT, NEO_GRB + NEO_KHZ800); void setup() { Serial.begin(115200); //while (!Serial) delay(10); // wait until serial port is opened Serial.println(F("Adafruit PID 5295 I2C QT Slide Potentiometer test!")); if (!seesaw.begin(DEFAULT_I2C_ADDR)) { Serial.println(F("seesaw not found!")); while(1) delay(10); } uint16_t pid; uint8_t year, mon, day; seesaw.getProdDatecode(&pid, &year, &mon, &day); Serial.print("seesaw found PID: "); Serial.print(pid); Serial.print(" datecode: "); Serial.print(2000+year); Serial.print("/"); Serial.print(mon); Serial.print("/"); Serial.println(day); if (pid != 5295) { Serial.println(F("Wrong seesaw PID")); while (1) delay(10); } if (!pixels.begin(DEFAULT_I2C_ADDR)){ Serial.println("seesaw pixels not found!"); while(1) delay(10); } Serial.println(F("seesaw started OK!")); pixels.setBrightness(255); // half bright pixels.show(); // Initialize all pixels to 'off' } void loop() { // read the potentiometer uint16_t slide_val = seesaw.analogRead(ANALOGIN); Serial.println(slide_val); for (uint8_t i=0; i< pixels.numPixels(); i++) { pixels.setPixelColor(i, Wheel(slide_val / 4)); } pixels.show(); delay(50); } // Input a value 0 to 255 to get a color value. // The colours are a transition r - g - b - back to r. uint32_t Wheel(byte WheelPos) { WheelPos = 255 - WheelPos; if(WheelPos < 85) { return seesaw_NeoPixel::Color(255 - WheelPos * 3, 0, WheelPos * 3); } if(WheelPos < 170) { WheelPos -= 85; return seesaw_NeoPixel::Color(0, WheelPos * 3, 255 - WheelPos * 3); } WheelPos -= 170; return seesaw_NeoPixel::Color(WheelPos * 3, 255 - WheelPos * 3, 0); }
After opening the NeoSlider.ino file, upload it to the Arduino wired to your NeoSlider. Open the Serial Monitor at 115200 baud. You should see the following as the sketch starts up.
Now try moving the potentiometer to see the values change and the NeoPixels change color.
That's all there is to using the NeoSlider with Arduino!
Dual NeoSlider Example
The Adafruit NeoSlider comes with two STEMMA QT connectors, making it super simple to chain up multiple sliders.
Dual I2C Wiring
Here is how to wire up two breakouts using two of the STEMMA QT connectors. The examples show a Metro but wiring will work the same for an Arduino or other compatible board.
- Board 1 VIN (red wire) to Arduino 5V
- Board 1 GND (black wire) to Arduino GND
- Board 1 SCL (yellow wire) to Arduino SCL
- Board 1 SDA (blue wire) to Arduino SDA
- Board 2 VIN (red wire) to board 1 VIN
- Board 2 GND (black wire) to board 1 GND
- Board 2 SCL (yellow wire) to board 1 SCL
- Board 2 SDA (blue wire) to board 1 SDA
// SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries // SPDX-License-Identifier: MIT /* * This example shows how read the potentiometer on two I2C QT Slide Potentiometers * and make the NeoPixels change too! */ #include "Adafruit_seesaw.h" #include <seesaw_neopixel.h> #define DEFAULT_I2C_ADDR 0x30 #define ANALOGIN 18 #define NEOPIXELOUT 14 Adafruit_seesaw seesaw1; Adafruit_seesaw seesaw2; seesaw_NeoPixel pixels1 = seesaw_NeoPixel(4, NEOPIXELOUT, NEO_GRB + NEO_KHZ800); seesaw_NeoPixel pixels2 = seesaw_NeoPixel(4, NEOPIXELOUT, NEO_GRB + NEO_KHZ800); void setup() { Serial.begin(115200); //while (!Serial) delay(10); // wait until serial port is opened Serial.println(F("Adafruit PID 5295 I2C QT Slide Potentiometer test!")); if (!seesaw1.begin(DEFAULT_I2C_ADDR) || !seesaw2.begin(DEFAULT_I2C_ADDR+1)) { Serial.println(F("seesaws not found!")); while(1) delay(10); } uint16_t pid; uint8_t year, mon, day; seesaw1.getProdDatecode(&pid, &year, &mon, &day); Serial.print("seesaw found PID: "); Serial.print(pid); Serial.print(" datecode: "); Serial.print(2000+year); Serial.print("/"); Serial.print(mon); Serial.print("/"); Serial.println(day); if (pid != 5295) { Serial.println(F("Wrong seesaw PID")); while (1) delay(10); } if (!pixels1.begin(DEFAULT_I2C_ADDR) || !pixels2.begin(DEFAULT_I2C_ADDR+1)){ Serial.println("seesaw pixels not found!"); while(1) delay(10); } Serial.println(F("seesaw started OK!")); pixels1.setBrightness(255); // half bright pixels2.setBrightness(255); // half bright pixels1.show(); // Initialize all pixels to 'off' pixels2.show(); // Initialize all pixels to 'off' } void loop() { // read the potentiometer uint16_t slide1_val = seesaw1.analogRead(ANALOGIN); uint16_t slide2_val = seesaw2.analogRead(ANALOGIN); Serial.print(slide1_val); Serial.print(", "); Serial.println(slide2_val); for (uint8_t i=0; i< pixels1.numPixels(); i++) { pixels1.setPixelColor(i, Wheel(slide1_val / 4)); pixels2.setPixelColor(i, Wheel(slide2_val / 4)); } pixels1.show(); pixels2.show(); delay(50); } // Input a value 0 to 255 to get a color value. // The colours are a transition r - g - b - back to r. uint32_t Wheel(byte WheelPos) { WheelPos = 255 - WheelPos; if(WheelPos < 85) { return seesaw_NeoPixel::Color(255 - WheelPos * 3, 0, WheelPos * 3); } if(WheelPos < 170) { WheelPos -= 85; return seesaw_NeoPixel::Color(0, WheelPos * 3, 255 - WheelPos * 3); } WheelPos -= 170; return seesaw_NeoPixel::Color(WheelPos * 3, 255 - WheelPos * 3, 0); }
After opening the Arduino_NeoSlider_Dual file, upload it to the Arduino wired to your NeoSlider. Open the Serial Monitor at 115200 baud to see the potentiometer values printed out.
Try moving the sliders to see the values and the NeoPixel colors change.
That's all there is to using two NeoSliders with Arduino!
Text editor powered by tinymce.