Potentio Indicator Uses RGB Neopixel
by MrSottong in Circuits > Arduino
1402 Views, 3 Favorites, 0 Comments
Potentio Indicator Uses RGB Neopixel

In this article I will make a rotation indicator of the potentio meter using RGB Nano pixel ring.
So, how many revolutions made on the potentiometer will be displayed on the RGB ring
Required Components




the components needed to make it :
- Arduino Nano v.3
- RGB RIng NeoPixels
- Potentiometer
- Jumper Wire
- USB mini
- Project Board
Circuit Schema


Assemble all components in accordance with the drawdown scheme above.
Arduino to Potensio & RGB Ring
+5V ==> 3.Potensio & VCC
GND ==> 1.Potensio & GND
A0 ==> 2.Potensio
D12 ==> IN
Programming

Copy the code below, and paste it into your sketch
<p>#include <br>#ifdef __AVR__ #include // Required for 16 MHz Adafruit Trinket #endif</p><p>#define PIN 12 #define NUMPIXELS 16 </p><p>Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);</p><p>#define DELAYVAL 10</p><p>void setup() {</p><p> #if defined(__AVR_ATtiny85__) && (F_CPU == 16000000) clock_prescale_set(clock_div_1); #endif</p><p>pixels.begin();</p><p>pixels.setBrightness(10); Serial.begin(9600); }</p><p>void loop() { pixels.clear(); int val = analogRead(A0); val = map(val, 0, 1023, 0, 18);</p><p> if(val == 1) { for(int i=0; i<1; i++) { pixels.setPixelColor(i, pixels.Color(0, 225, 0)); delay(10); } }</p><p> if(val == 2) { for(int i=0; i<2; i++) { pixels.setPixelColor(i, pixels.Color(32, 225, 0)); delay(10); } }</p><p> if(val == 3) { for(int i=0; i<3; i++) { pixels.setPixelColor(i, pixels.Color(64, 225, 0)); delay(10); } }</p><p> if(val == 4) { for(int i=0; i<4; i++) { pixels.setPixelColor(i, pixels.Color(96, 225, 0)); delay(10); } }</p><p> if(val == 5) { for(int i=0; i<5; i++) { pixels.setPixelColor(i, pixels.Color(128, 225, 0)); delay(10); } }</p><p> if(val == 6) { for(int i=0; i<6; i++) { pixels.setPixelColor(i, pixels.Color(160, 225, 0)); delay(10); } }</p><p> if(val == 7) { for(int i=0; i<7; i++) { pixels.setPixelColor(i, pixels.Color(192, 225, 0)); delay(10); } }</p><p> if(val == 8) { for(int i=0; i<8; i++) { pixels.setPixelColor(i, pixels.Color(225, 225, 0)); delay(10); } }</p><p> if(val == 9) { for(int i=0; i<9; i++) { pixels.setPixelColor(i, pixels.Color(225, 225, 0)); delay(10); } }</p><p> if(val == 10) { for(int i=0; i<10; i++) { pixels.setPixelColor(i, pixels.Color(225, 192, 0)); delay(10); } }</p><p> if(val == 11) { for(int i=0; i<11; i++) { pixels.setPixelColor(i, pixels.Color(225, 160, 0)); delay(10); } }</p><p> if(val == 12) { for(int i=0; i<12; i++) { pixels.setPixelColor(i, pixels.Color(225, 128, 0)); delay(10); } }</p><p> if(val == 13) { for(int i=0; i<13; i++) { pixels.setPixelColor(i, pixels.Color(225, 96, 0)); delay(10); } }</p><p> if(val == 14) { for(int i=0; i<14; i++) { pixels.setPixelColor(i, pixels.Color(225, 64, 0)); delay(10); } }</p><p> if(val == 15) { for(int i=0; i<15; i++) { pixels.setPixelColor(i, pixels.Color(225, 32, 0)); delay(10); } }</p><p> if(val == 16) { for(int i=0; i<16; i++) { pixels.setPixelColor(i, pixels.Color(225, 0, 0)); delay(10); } }</p><p> if(val == 17) { for(int i=0; i<17; i++) { pixels.setPixelColor(i, pixels.Color(225, 0, 0)); delay(10); } }</p><p> if(val == 18) { for(int i=0; i<18; i++) { pixels.setPixelColor(i, pixels.Color(225, 0, 0)); delay(10); } } pixels.show(); delay(DELAYVAL); }</p>
Sketch file can be downloaded below:
Downloads
Result

For results can be seen in the video above.
So every time the potentiometer is rotated, the number and color of the LEDs on the ring will light up according to the number of turns done on the potentiometer.