Can someone help me. In the German forum has "Jurs" wrote this code, but the problem is, I can't make determine breaks between the LED lights sequence, because "delay(1000);" don't work right ? How I can do that?
// Struktur für eine LED
struct led_t { byte pin; int zeit; char wert; };
// Array für alle LEDs
led_t leds[]={
{ 2, 500, 'A' }, // Red PIN 2
{ 3, 200, 'B' }, // Yellow PIN 3
{ 4, 100, 'C' }, // Green PIN 4
{ 5, 200, 'D' }, // Blue PIN 5
};
char playList[]="BCABDCBADBCABDCBADBCBADCBBCBCDABBDCABDC";
int playIndex=0;
int ledIndex=0;
#define NUMLEDS (sizeof(leds)/sizeof(leds[0]))
void setup () {
Serial.begin(9600);
Serial.println("Start");
for(int i=0; i<NUMLEDS; i++)
{
pinMode(leds[i].pin, OUTPUT);
}
Serial.print(leds[ledIndex].wert);
digitalWrite(leds[ledIndex].pin,HIGH);
}
unsigned long letzterWechsel;
void loop() {
static byte start = 0;
if(millis()-letzterWechsel >= leds[ledIndex].zeit && !start)
{
letzterWechsel+= leds[ledIndex].zeit;
digitalWrite(leds[ledIndex].pin,LOW);
playIndex++;
if (playIndex>=strlen(playList))
{
start = 1;
playIndex=0; // Am Ende Überlauf auf null
Serial.println(); // Neue Zeile auf Serial beginnen
while(1); // Ende mit Endlosschliefe
}
if (playList[playIndex]=='A') ledIndex=0;
else if (playList[playIndex]=='B') ledIndex=1;
else if (playList[playIndex]=='C') ledIndex=2;
else if (playList[playIndex]=='D') ledIndex=3;
digitalWrite(leds[ledIndex].pin,HIGH);
Serial.print(leds[ledIndex].wert);
}
}