I am a bit late on this topic, considering that a lot of tutorial already exists in the internet. Two weeks ago, I had the chance to get my hands on an Arduino Uno board. It is the same as the one raffled at 1Diy
But what a waist it would be if I accidentally smoke that board while I am on my quest to the Arduino world, so Severino was born.
Severino 3 version 3 is the latest version of single sided board arduino that is officially supported by Arduino. It can be loaded with bootloader for Diecimila, Duemilanove, Nano, and Arduino Pro. I uploaded the bootloader using Arduino Uno with ArduinoISP loaded. First I tried Duemilanove bootloader and it uploaded successfully. But the moment I tried to upload a sketch, my 3 hours of **** scratching begins
. It turned out that the auto reset function is a hit or miss affair with this board. Tried uploading the bootloader several times but to no avail. So before I throw the towel, I loaded the Arduino pro bootloader and attempted to upload a sketch for the last time. This time, I hit the reset switch just after pressing the upload button in the Arduino IDE, and it works! I should've done it earlier to save me some frustration but I guess its the price to pay for not doing the RTFM.
With Severino working, I can now continue being the Arduino late bloomer and share with you my experience programming arduino. I wont be risking the life of that shiny green Arduino Uno so you'll be seing severino for the rest of this thread.
What I am going to share here is not arranged according to complexity. It'll all depends on what I have worked on previously that I thought might be useful to my hobby. All information presented here are not guaranteed against error and should be treated as such. Corrections are very much welcome
With that in mind, lets start with PWM. PWM or Pulse Width Modulation is simply defined as
(Pulse Width Modulation) A modulation technique that generates variable-width pulses to represent the amplitude of an analog input signal.
For us hobbyist, let us not dabble with the formulas. Ill save myself from trouble so Ill just introduce frequency and duty cycle here the way I understand it.
Frequency is the number of occurrences of a repeating event per unit time.
In engineering, the duty cycle of a machine or system is the time that it spends in an active state as a fraction of the total time under consideration.
(image taken from arduino website)
It is as simple as the illustration above. Frequency is how many times it cycle on/off in 1 second and duty cycle is how long it stays on during that cycle. PWM in arduino can be achieved by simply calling the analogWrite(pinNumber, dutyCycle)
function. The default frequency is default to 500Hz so you have 2mS per on/off cycle. Duty cycle is expressed from 0 to 255, 255 being 100% duty cycle.
I have uploaded the sketch from the Examples menu of ArduinoIDE and here's what I got
Using 4 x 1W LED
Notice the lines in the second video? It is the duty cycle working its magic. When the line is longer (higher duty cycle), the light becomes brighter, that means the pwm pin is high most of the time, causing the target to see more voltage from this pin, say at 75% duty cycle the target sees around 3.75V if the pins logic high is @5V. Its quite simple right? We can now control our mobots speed by applying pwm to the motor controller.
Thats all for today, good morning.