# Arduino LED Ring with Variable Rotational Speed

This is just a fun Arduino project that uses leds connected in circle as a ring to produce a rotation effect. You can adjust the spinning speed with a potentiometer and you can also set a minimum and maximum speed in the code. You will need an Arduino board, a potentiometer (I have used a 50K one), as many leds as you want and the same amount of resistors.

Schematic of the Arduino LED Ring Circuit

## Video presentation of the led ring project

Arduino LED Ring Sketch Code

```/* source: http://www.electroschematics.com/9820/arduino-led-ring/ */
const byte leds = 8; // how many leds
byte pins[] = {5, 6, 7, 8, 9, 10, 11, 12}; // pins to connect leds
int pot = A1;
int minSpeed = 500; // put a high value
int maxSpeed = 50;  // put a low value

void setup()
{
for(int i = 0; i < leds; i++) {
pinMode(pins[i], OUTPUT);
}
pinMode(pot, INPUT);
}

void loop()
{
for(int i = 0; i < leds; i++) {
digitalWrite(pins[i], HIGH);
int speed = map(valPot, 0, 1023, minSpeed, maxSpeed);
delay(speed);
digitalWrite(pins[i], LOW);
}
}
```

As you can see the code is quite simple and can be adapted for any number of leds that your Arduino board allows. You can use shift register ICs like 74HC595 to connect more leds and free the pins on your Arduino board.

The only interesting part inside the code is at line #18 inside the for() loop where we put each pin one by one in high state(#19) then we read the value from the potentiometer (#20) and map it to different values (#21). Then store this value inside the speed variable that is used in the delay() to control how much time to wait until the led is turned off (#23).