Hi,
I am Varma from India. I am working on arduino. i want to generate a PWM signal with time of 40 mSec. how should I change the time ????
Hi,
I am Varma from India. I am working on arduino. i want to generate a PWM signal with time of 40 mSec. how should I change the time ????
http://arduino.cc/en/Tutorial/SecretsOfArduinoPWM
It seems you might have to do some calculations to see if you can get that value out of an arduino. Good luck.
Hi
u want 40ms time period in your pwm
But what duty cycle do u want?
see time period is on time + off time
I think u want 50% duty cycle
so 20ms on time
and 20ms off time
you can simply use digital write and delay
similar to blink program but your delay will be according to on time and off time
the delay after writing high in the pin is your on time
and that after writing low is your off time
Hope it helped
I would suggest you use the pwm library for this purpose as using delay() will cause all processing to suspend while the delay is going on, this is ok if the only think you want the Arduino to do is output the PWM signal but is now good once you want to do other things
The PWM library allows you do do other things and makes setting the parameters much simpler
See http://arduino.cc/en/Tutorial/SecretsOfArduinoPWM
And
https://code.google.com/p/arduino-pwm-frequency-library/
Hope this helps
Peter
Well a solution to the problem with delay
is with using milllis()
https://learn.adafruit.com/multi-tasking-the-arduino-part-1/now-for-two-at-once
With this we can multi thread arduino (kindof)
and prevent arduino from suspending when delay is required
and with all due respect sir
I dont like using libraries too much
1 they consume lots of space the functions that you may not require too come into rom
2 It makes it hard to optimize your system which is first priority of modern embedded system design
3 you are unable to understand the details of what is happening for example lcd seems easy but study how its to be done in ALP and than see the library of lcd and you will start to understand the details which the library was hiding from you