Flora PWM pins

by tektsu on Sun Feb 10, 2013 6: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 4:07 pm

Re: Flora PWM pins

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

User avatar
adafruit_support_bill
 
Posts: 28809
Joined: Sat Feb 07, 2009 9:11 am

Re: Flora PWM pins

by tektsu on Mon Feb 11, 2013 8: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 4:07 pm

Re: Flora PWM pins

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

The 32U4 does have hardware PWM. Not sure why analogWrite wouldn't work. I'll look into it.
User avatar
adafruit_support_bill
 
Posts: 28809
Joined: Sat Feb 07, 2009 9:11 am

Re: Flora PWM pins

by adafruit on Mon Feb 11, 2013 10: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);
}
User avatar
adafruit
 
Posts: 11663
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: Flora PWM pins

by tektsu on Mon Feb 11, 2013 11:26 am

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 4:07 pm

Re: Flora PWM pins

by tektsu on Mon Feb 11, 2013 6: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 4:07 pm

Re: Flora PWM pins

by adafruit_support_bill on Mon Feb 11, 2013 6: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.
User avatar
adafruit_support_bill
 
Posts: 28809
Joined: Sat Feb 07, 2009 9:11 am

Re: Flora PWM pins

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

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