PWM with Arduino - step by step guide

Small step by step guide on how to use the PWM (Pulse Width Modulation) of the Arduino board. The video includes the components needed and an easy to follow connection guide, as well as a demo of the results obtained. The code is also included. Try it out yourself, enjoy! :D
What about doing it with Synapse modules rf engines? <br>Have you heard about them?
What kind of motor are you using?
The motor used in the example is just a cheap regular DC motor. The kind of you can find in &quot;science kits&quot; for kids.
A modified Sketch that actually works with HS 422 servo, Gertboard and Raspberry Pi: <br>http://www.linuxcircle.com/?p=640 <br> <br>You do not need servo.h library
Very nice elaboration. <br>Will you specify what transistor you were using? <br>
The code is a bit difficult to read in the video, could you please post it on your instructable?
Here is a link to the code: <a href="https://docs.google.com/document/d/1sVM4R4C8etX_34tTUtQkLbK3lBE_LEjYgY0WJMRuDi0/edit?pli=1" rel="nofollow">https://docs.google.com/document/d/1sVM4R4C8etX_34tTUtQkLbK3lBE_LEjYgY0WJMRuDi0/edit?pli=1</a><br> <br> And here the code itself:<br> <br> int motor = 9;<br> int potenciometer = 5;<br> <br> void setup(){<br> &nbsp; pinMode(9,OUTPUT);<br> &nbsp; pinMode(5,INPUT);<br> &nbsp;<br> &nbsp; Serial.begin(9600);<br> }<br> <br> void loop(){<br> &nbsp; int value = analogRead(potenciometer);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//read input value: range between (0,1023)<br> &nbsp; int motor_speed = value/4;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //PWM can only ouput 255 different values<br> &nbsp;<br> &nbsp; analogWrite(motor,motor_speed);<br> &nbsp;<br> &nbsp; Serial.println(motor_speed);//for testing purposes<br> }
Useful and straight to the point - keep them coming!<br>
Thanks, they will be more comming for sure :)

About This Instructable


24 favorites


More by jgrecoarroyo: LED experiment: choose correct resistor! EEG - brain computer interface PWM with Arduino - step by step guide
Add instructable to: