Jump to content
43oh

KJH

Members
  • Content Count

    4
  • Joined

  • Last visited

Reputation Activity

  1. Like
    KJH reacted to energia in [SOLVED] PWM Frequency in Energia   
    Move the call to analogFrequency(800); into setup. Only call analogWrite when the duty cycle is changed.
     
    Below is a copy of the Fading Sketch as an example: 
     
    int ledPin = 9; // LED connected to digital pin 9 void setup() { // nothing happens in setup analogFrequency(800); } void loop() { // fade in from min to max in increments of 5 points: for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) { // sets the value (range from 0 to 255): analogWrite(ledPin, fadeValue); // wait for 30 milliseconds to see the dimming effect delay(30); } // fade out from max to min in increments of 5 points: for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) { // sets the value (range from 0 to 255): analogWrite(ledPin, fadeValue); // wait for 30 milliseconds to see the dimming effect delay(30); } }
  2. Like
    KJH reacted to L.R.A in [SOLVED] PWM Frequency in Energia   
    I had the same problem. Just call the PWM fuction when you change duty.
    Look here, it's for a stellaris but the principle is the same:
    http://forum.stellarisiti.com/topic/1798-pwm-changes-depending-on-the-code-its-running/
×
×
  • Create New...