Memorial day is 05/25/2015 – Orders will ship out on May 26th. There will not be any deliveries or shipping on Monday. Any order placed after 11am ET on Friday May 22nd will not start to ship out until Tuesday May 26th.

Flora PWM pins
Moderators: adafruit_support_bill, adafruit

Flora PWM pins

by tektsu on Sun Feb 10, 2013 7:59 pm

What pins support PWM on the Flora? I am trying to use analogWrite(), but the pins I have tried (D9 and D11) don't seem to support it.
Thanks
tektsu
 
Posts: 18
Joined: Sun Nov 15, 2009 5:07 pm

Re: Flora PWM pins

by adafruit_support_bill on Mon Feb 11, 2013 8:36 am


adafruit_support_bill
 
Posts: 37544
Joined: Sat Feb 07, 2009 10:11 am

Re: Flora PWM pins

by tektsu on Mon Feb 11, 2013 9:37 am

I had seen that tutorial, and it *does* say that D9 supports PWM, however, unless I am misunderstanding the code, it's doing the PWM in software, not using analogWrite(). analogWrite() does not seem to work on that pin. Is there a pin which will support analogWrite?
tektsu
 
Posts: 18
Joined: Sun Nov 15, 2009 5:07 pm

Re: Flora PWM pins

by adafruit_support_bill on Mon Feb 11, 2013 10:15 am

The 32U4 does have hardware PWM. Not sure why analogWrite wouldn't work. I'll look into it.

adafruit_support_bill
 
Posts: 37544
Joined: Sat Feb 07, 2009 10:11 am

Re: Flora PWM pins

by adafruit on Mon Feb 11, 2013 11:39 am

Try this? its our flora analog output test code :)

Code: Select all | TOGGLE FULL SIZE
void setup() {
  pinMode(6, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);

  analogWrite(6, 66);
  analogWrite(9, 128);
  analogWrite(10, 194);
}


void loop() {
  delay(100);
}

adafruit
 
Posts: 11905
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

Re: Flora PWM pins

by tektsu on Mon Feb 11, 2013 12:26 pm

I will give it a try this evening when I get home, and I'll let you know the results.
Thanks
tektsu
 
Posts: 18
Joined: Sun Nov 15, 2009 5:07 pm

Re: Flora PWM pins

by tektsu on Mon Feb 11, 2013 7:15 pm

I hooked up LEDs and resistors to the pins 6, 9 and 10. I used the same kind of LEDs from the same package, so they should be similar, and I used the same value resistor for each LED. Using your sample program, all three LEDs come on and appear to be the same brightness.

However, using the following code, I can see that there is a slight difference between the three, although the one set at 194 does not appear to blink.

Code: Select all | TOGGLE FULL SIZE
void setup() {
  pinMode(6, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
}


void loop() {
  analogWrite(6, 66);
  analogWrite(9, 128);
  analogWrite(10, 194);
  delay(500);
  digitalWrite(6, HIGH);
  digitalWrite(9, HIGH);
  digitalWrite(10, HIGH);
  delay(500);
}


So apparently the PWM is working, but perhaps the duty cycle is not as expected.

I recently moved, and of course I can't find my o-scope probes now. :( I'll pick up a new set when I get into town and see if I can see what's up.

Thanks for your help.
tektsu
 
Posts: 18
Joined: Sun Nov 15, 2009 5:07 pm

Re: Flora PWM pins

by adafruit_support_bill on Mon Feb 11, 2013 7:25 pm

LED response in general is not linear. For most of them, you need to reduce the duty cycle considerably before it visibly dims. I wouldn't expect 194 to be much different than 255.

adafruit_support_bill
 
Posts: 37544
Joined: Sat Feb 07, 2009 10:11 am

Re: Flora PWM pins

by tektsu on Tue Feb 12, 2013 9:43 am

Yep, further testing shows everything is working as it should. Thanks for your help!
tektsu
 
Posts: 18
Joined: Sun Nov 15, 2009 5:07 pm



cron