Hope someone is feeling creative out there. I am currently building a digital pinball with LED's in the side of the cabinet
Using an Ardunio Mega for the control of a few different sequences. I am still in the learning stages with coding.
Basically I am using a timer to trigger a frame on the LEDs to create sequances, then after a set time, turn the LED's into a VU meter. Works pretty well and I am happy with the outcome.
I was using just a pulsing PWM for the centre LED which I am using a super bright Cree LED in, but it seems too rythmatic and generic compared to the rest of it.
Anyone got ideas on what to do witht the centre LED? Would really appreciate some insperation cause I am drawing a blank.
Example of the main parts of my code.
void loop(void) {
//Accumulate ISR latency every 10ms.
delay(10);
sampleCount++;
sampleCount2++;
//centre LED loop
time = millis();
value = 128+127*cos(2*PI/periode*time);
value2 = 128+127*cos(2*PI/periode*(displace-time));
analogWrite(ledpin, value); // sets the value (range from 0 to 255)
analogWrite(ledpin2, value2); // sets the value (range from 0 to 255)
//circle LED sequences
if(sampleCount == 10 || sampleCount == 190 || sampleCount == 230 || sampleCount == 410 || sampleCount == 620 ) { //loop 1,2 & 3
setLEDs(1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1);
}
if(sampleCount == 20 || sampleCount == 180 || sampleCount == 240 || sampleCount == 400 || sampleCount == 450 || sampleCount == 610 || sampleCount == 660) {
setLEDs(0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0);
}
if(sampleCount == 30 || sampleCount == 170 || sampleCount == 250 || sampleCount == 390 || sampleCount == 460 || sampleCount == 600 || sampleCount == 670) {
setLEDs(0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0);
}
if(sampleCount == 40 || sampleCount == 160 || sampleCount == 260 || sampleCount == 380 || sampleCount == 470 || sampleCount == 590 || sampleCount == 680) {
setLEDs(0,0,0,1,1,0,0,0,0,0,0,0,0,0,1,1,0,0,0);
}
etc..... this section went on for a while
if(sampleCount > 3400) {
total -= readings[index];
readings[index] = analogRead(A0);
total += readings[index];
index = (index + 1);
if (index >= NUMREADINGS)
index = 0;
average = total / NUMREADINGS;
val = analogRead(0);
ledpwm =(val/4);
analogWrite(ledpin, ledpwm); // sets the value (range from 0 to 255)
analogWrite(ledpin2, ledpwm); // sets the value (range from 0 to 255)
if(average > val){
setLEDs(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
Serial.print(average);
}
if(average > val+10){
setLEDs(1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1);
Serial.print(average);
}
if(average > val+20){
setLEDs(1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1);
Serial.print(average);
}
if(average > val+30){
setLEDs(1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1);
Serial.print(average);
}
if(average > val+40){
setLEDs(1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1);
Serial.print(average);
}
etc....
}
//Once we have 101 samples, calculate and output the measurements
if(sampleCount>6000) {
sampleCount=-1;
}
}
void setLEDs(byte bL18, byte bL17, byte bL16, byte bL15, byte bL14,byte bL13, byte bL12, byte bL11,byte bL10, byte bL9, byte bL8,byte bL7, byte bL6,byte bL5, byte bL4, byte bL3,byte bL2, byte bL1, byte bL0)
{
digitalWrite(LED0, bL0);
digitalWrite(LED1, bL1);
digitalWrite(LED2, bL2);
digitalWrite(LED3, bL3);
digitalWrite(LED4, bL4);
digitalWrite(LED5, bL5);
digitalWrite(LED6, bL6);
digitalWrite(LED7, bL7);
digitalWrite(LED8, bL8);
digitalWrite(LED9, bL9);
digitalWrite(LED10, bL10);
digitalWrite(LED11, bL11);
digitalWrite(LED12, bL12);
digitalWrite(LED13, bL13);
digitalWrite(LED14, bL14);
digitalWrite(LED15, bL15);
digitalWrite(LED16, bL16);
digitalWrite(LED17, bL17);
digitalWrite(LED18, bL18);
}
void setLED2s(byte bL23,byte bL22, byte bL21, byte bL20)
{
digitalWrite(LED20, bL20);
digitalWrite(LED21, bL21);
digitalWrite(LED22, bL22);
digitalWrite(LED23, bL23);
}