Scriptproblem: LED-Folge

4 LED an dig. Out. 6, 7, 8 und 9

Jeweils eine LED soll 1 sec. leuchten (High) sowie eine benachbarte (pulseWith)
(Das funktioniert aber nur für LED 7 und 9 High + benachbarte LED

Wo liegt der Fehler?

int pulseWidth = 10; // Any value between 0 and 255

void setup() {
}

void loop() {
analogWrite(9, pulseWidth);
digitalWrite(6, HIGH); // set the LED on
delay(1000); // wait for a second
analogWrite(9, LOW);
digitalWrite(6, LOW);
delay(100); // wait for a second
analogWrite(6, pulseWidth);
digitalWrite(7, HIGH); // set the LED on
delay(1000); // wait for a second
analogWrite(6, LOW); // set the LED off
digitalWrite(7, LOW); // set the LED off
delay(100);
analogWrite(7, pulseWidth);
digitalWrite(8, HIGH); // set the LED on
delay(1000); // wait for a second
analogWrite(7, LOW); // set the LED off
digitalWrite(8, LOW); // set the LED off
delay(100);
analogWrite(8, pulseWidth);
digitalWrite(9, HIGH); // set the LED on
delay(1000); // wait for a second
analogWrite(8, LOW); // set the LED off
digitalWrite(9, LOW); // set the LED off
delay(100);
}

Blink_2xoutput_PWM.pde (1.15 KB)

Vielleicht weil 7 und 8 keine PWM Ausgänge sind?
Uwe

welche Ausgänge sind PWM geeignete Ausgänge beim Arduino Duemilanove?

Die an denen PWM steht (3,5,6,9,10,11) :wink:

Herzlichen Dank !!!

Da wo PWM neben dem AUsgang drauf steht also 3,5,6,9,10,11. Mit dieser Funktion.

unsigned long pmicros;
int nextCall=HIGH;
int val=0;


void setup(){
  pinMode(13,OUTPUT);
 pinMode(12,OUTPUT);
 }

void loop(){
val=analogRead(0);
val=map(val,0,1023,1,100);
  Low_PWM(12,30,val);
  }

void Low_PWM(int Pin, int Fre, int Value){
long time;
long ontime;
time=1000000/Fre;
  ontime=time/100*Value;
  if (micros() - pmicros > time && nextCall==HIGH) {
    digitalWrite(Pin,HIGH);
    pmicros=micros();
    nextCall=LOW;
  }
  if (micros() - pmicros > ontime&& nextCall==LOW){ 
    digitalWrite(Pin,LOW);
    nextCall=HIGH;  
  }
}

Kannst du PWM mit ca 30Hz auf jedemdigitalen Ausgang benutzen

Wenn Du Englisch lesen kannst, ich habe gerade jede Menge Varianten wie man LEDs "unabhängig" blinken kann hier breitgetreten:

Insbesondere auch mit ziemlich hochfrequentem Software PWM: