RGB RingCoder is a breakout board, a circular LED containing 16 LEDs arranged in a ring, and a rotary encoder. The encoder contains an RGB LED as well as a push button function.
The device requires 11 pins, 3 of which must be PWM-capable (for the RGB LEDs).
new upm::RGBRingCoder(4, 10, 11, 2, 9, 7, 12, 13, 3, 5, 6);
uint16_t spin = 0x0001;
bool oldState = false;
int oldPos = 0;
while (shouldRun)
{
if (spin == 0)
spin = 0x0001;
ringCoder->setRingLEDS(spin);
spin <<= 1;
if (bstate != oldState)
{
cout << "Button state changed from " << oldState << " to "
<< bstate << endl;
oldState = bstate;
}
int epos = ringCoder->getEncoderPosition();
if (epos != oldPos)
{
cout << "Encoder position changed from " << oldPos << " to "
<< epos << endl;
oldPos = epos;
}
usleep(100000);
}