Instructables

PWM with Arduino - step by step guide

video 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
saarp1810 months ago
What about doing it with Synapse modules rf engines?
Have you heard about them?
Veda8811 months ago
What kind of motor are you using?
jgrecoarroyo (author)  Veda8811 months ago
The motor used in the example is just a cheap regular DC motor. The kind of you can find in "science kits" for kids.
pratyadi1 year ago
A modified Sketch that actually works with HS 422 servo, Gertboard and Raspberry Pi:
http://www.linuxcircle.com/?p=640

You do not need servo.h library
rclear1 year ago
Very nice elaboration.
Will you specify what transistor you were using?
The code is a bit difficult to read in the video, could you please post it on your instructable?
jgrecoarroyo (author)  alien2000496552 years ago
Here is a link to the code: https://docs.google.com/document/d/1sVM4R4C8etX_34tTUtQkLbK3lBE_LEjYgY0WJMRuDi0/edit?pli=1

And here the code itself:

int motor = 9;
int potenciometer = 5;

void setup(){
  pinMode(9,OUTPUT);
  pinMode(5,INPUT);
 
  Serial.begin(9600);
}

void loop(){
  int value = analogRead(potenciometer);
                     //read input value: range between (0,1023)
  int motor_speed = value/4;
                    //PWM can only ouput 255 different values
 
  analogWrite(motor,motor_speed);
 
  Serial.println(motor_speed);//for testing purposes
}
agreco52 years ago
Useful and straight to the point - keep them coming!
jgrecoarroyo (author)  agreco52 years ago
Thanks, they will be more comming for sure :)