Pages: [1]   Go Down
Author Topic: Scriptproblem: LED-Folge  (Read 527 times)
0 Members and 1 Guest are viewing this topic.
Berlin
Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 - downloaded 2 times.)
Logged

Forum Moderator
BZ (I)
Online Online
Brattain Member
*****
Karma: 271
Posts: 21873
+39 349 2158303
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Berlin
Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
God Member
*****
Karma: 10
Posts: 721
42
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Die an denen PWM steht (3,5,6,9,10,11) smiley-wink
Logged


Berlin
Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Herzlichen Dank !!!
Logged

AREA COLOGNE
Offline Offline
Edison Member
*
Karma: 21
Posts: 1145
I am 1 of 10 who understands binary
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:
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
Logged

So ist das Leben:
Manchmal bis du das Denkmal, manchmal die Taube!

0
Offline Offline
Faraday Member
**
Karma: 24
Posts: 3496
20 LEDs are enough
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Wenn Du Englisch lesen kannst, ich habe gerade jede Menge Varianten wie man LEDs "unabhängig" blinken kann hier breitgetreten:
http://blog.blinkenlight.net/experiments/basic-effects/

Insbesondere auch mit ziemlich hochfrequentem Software PWM:
http://blog.blinkenlight.net/experiments/removing-flicker/


Logged

Check out my experiments http://blog.blinkenlight.net

Pages: [1]   Go Up
Jump to: