Hi Guys, hoping someone out there can help me? Let me start by saying I am a complete beginner when it comes to Arduino and have been getting help from a friend who is unfortunately not around to help me with an issue i'm having at the moment.
I have designed a furniture product (my real talent!) which has a semi circle of 10 LEDs built into it. In the past, my friend had the LEDs linked up to a slide potentiometer which sequentially turned on all 10 of the LEDs as the slider moved to the right and sequentially turned them off as the slider moved to the left.
The code looked like this :
const int analogPin = A0; // the pin that the potentiometer is attached to
const int ledCount = 10; // the number of LEDs in the bar graph
int ledPins[] = {
2, 3, 4, 5, 6, 7,8,9,10,11 }; // an array of pin numbers to which LEDs are attached
void setup() {
// loop over the pin array and set them all to output:
for (int thisLed = 0; thisLed < ledCount; thisLed++) {
pinMode(ledPins[thisLed], OUTPUT);
}
}
void loop() {
// read the potentiometer:
int sensorReading = analogRead(analogPin);
// map the result to a range from 0 to the number of LEDs:
int ledLevel = map(sensorReading, 0, 1023, 0, ledCount);
// loop over the LED array:
for (int thisLed = 0; thisLed < ledCount; thisLed++) {
// if the array element's index is less than ledLevel,
// turn the pin for this element on:
if (thisLed < ledLevel) {
digitalWrite(ledPins[thisLed], HIGH);
}
// turn off all pins higher than the ledLevel:
else {
digitalWrite(ledPins[thisLed], LOW);
}
}
}
The purpose of this was so I could use the slide potentiometer to demonstrate a hypothetical reality, in which the LEDs would fluctuate on their own based on a data input.
The project is on show at an event next week but I won't be there to demonstrate the LEDs using the slide potentiometer.
Basically I want the ring of 10 LEDs to come on and off sequentially (always ascending or descending, adding or subtracting one at a time) in a random order. I would like them to fluctuate 'randomly' while still following the correct order (1-10) with only one LED changing at a time.
When I say 'random' I mean I don't want them to go; 1,2,3,4,5,6,7,8,9,10,9,8,7,6,5,4,3,2,1 on a loop.. I want something along the lines of: 1,2,3,4,5,6,5,4,5,6,7,8,9,8,7,8,7,6,5,6,7,8,9,10,9 etc.. 'randomly' moving up and down the scale one at a time.
This is a youtube product video I made to demonstrate the idea. it should give a clearer idea of what i want to achieve LUX - A SAD lamp to smile about. - YouTube
Any help in achieving this would be hugely appreciated! Thanks.