[OpenTRV-dev] OT: pulse output from arduino
Damon Hart-Davis
EMAIL ADDRESS HIDDEN
Tue May 28 20:29:35 BST 2013
Hi,
1) That's quite power hungry with no sleep() which you may want to address.
2) It'll do something funny at ~49 days, when the millis() internal counter rolls.
3) If analogueWrite() uses hardware PWM then you should be able to, say, replace:
if (ledState == LOW)
ledState = HIGH;
else
ledState = LOW;
// set the LED with the ledState of the variable:
digitalWrite(ledPin, ledState);
with (say):
++ledState;
analogueWrite(ledPin, ledState & 0xff);
to generate a slowly-rising saw-tooth (PWMed) for example, though I haven't tried it.
Rgds
Damon
On 28 May 2013, at 19:59, Bo Herrmannsen wrote:
> i was given this example: http://arduino.cc/en/Tutorial/BlinkWithoutDelay
>
>
> but is there a way to call this and just give it a i number like analogwrite?
>
> /bo
>
> 2013/5/26 Damon Hart-Davis <EMAIL ADDRESS HIDDEN>
> Duty cycle is the fraction of the time the output is HIGH and is nominally independent of the frequency.
>
> Rgds
>
> Damon
>
>
> On 26 May 2013, at 19:15, Bo Herrmannsen wrote:
>
> > Hi
> >
> > fighting a small thing here... i know i can use the pwm out for pulses... but how do i know for sure it gives say 3 pulses a sec? i calced something about a duty cycle of 50-60%
> >
> > but is there a more precise way?
> >
> >
> > /bo
> > _______________________________________________
> > OpenTRV-dev mailing list
> > EMAIL ADDRESS HIDDEN
> > http://lists.opentrv.org.uk/listinfo/opentrv-dev
>
> _______________________________________________
> OpenTRV-dev mailing list
> EMAIL ADDRESS HIDDEN
> http://lists.opentrv.org.uk/listinfo/opentrv-dev
>
> _______________________________________________
> OpenTRV-dev mailing list
> EMAIL ADDRESS HIDDEN
> http://lists.opentrv.org.uk/listinfo/opentrv-dev
More information about the OpenTRV-dev
mailing list