BRUTE FORCE
ELECTRONICS-PROGRAMMING-ROBOTICS
Course Overview
▪ Week 1 – Electronics
▪ Week 2 – Programming
▪ Week 3 – Arduino
▪ Week 4 – Robotics
Tutorial 3
Arduino Controls
Focus
● Pulse Width Modulation
● Controlling a DC Motor
Arduino Pulse Width Modulation
● Pulse Width Modulation or PWM is a common technique used to vary the width of the pulses in a
pulse-train.
● PWM is a technique by which width of a pulse is varied while keeping the frequency of the wave
constant. It is a method for generating an analog signal using a digital source.
● It has many applications such as controlling servos and speed controllers, limiting the effective
power of motors and LEDs.
PWM Basic Principle
● Pulse width modulation is basically, a square wave with a varying
high and low time.
● There are various terms associated with PWM −
➢ On-Time − Duration of time signal is high.
➢ Off-Time − Duration of time signal is low.
➢ Period − It is represented as the sum of on-time and off-time of
PWM signal.
➢ Duty Cycle − It is represented as the percentage of time signal
that remains on during the period of the PWM signal.
PWM Pins of Arduino
● Arduino Uno has 6 8-bit PWM channels. The pins
with symbol ‘~’ represents that it has PWM support.
Arduino Functions for PWM
● analogWrite() Function
analogWrite (pin, duty cycle)
● pin – pin on which we want to generate pwm or analog signal.
● duty cycle – it lies in between 0 (0%, always off) – 255 (100%, always on).
➢ The function writes an analog value (PWM wave) to a pin.
➢ It is used to generate PWM or output analog value to a specified PWM channel.
➢ It can be used to light a LED at varying brightness or drive a motor at various speeds. After a call of the
analogWrite() function, the pin will generate a steady square wave of the specified duty cycle until the
next call to analogWrite() or a call to digitalRead() or digitalWrite() on the same pin.
➢ The frequency of the PWM signal on most pins is approximately 490 Hz.
LED Fading using Arduino PWM
A program in which led will fade
continuously. This led fading application
used for decoration in functions and
festivals.
Control LED Brightness using Potentiometer
Arduino DC Motor
● There are three different type of motors −
➢ DC motor
➢ Servo motor
➢ Stepper motor
● Direct Current (DC) MOTOR - is the most common type of motor. DC motors normally have just
two leads, one positive and one negative. If you connect these two leads directly to a battery, the
motor will rotate. If you switch the leads, the motor will rotate in the opposite direction.
Reading Analog and Digital Inputs
You will need:
Arduino board
Breadboard
LED
220 ohm resistor
potentiometer
Motor Spin Control
● You will need:
Arduino UNO board
PN2222 Transistor
6V DC Motor
1N4001 diode
270 Ω Resistor
Warning − Do not drive the motor directly
from Arduino board pins. This may
damage the board. Use a driver Circuit or
an IC.
Motor Spin Control
● The transistor acts like a switch, controlling the power
to the motor. Arduino pin 3 is used to turn the transistor
on and off
Motor Speed Control
THANK YOU ARDUINO GEEKS!
IGNITING CREATIVITY - LEARN BY DOING
BRUTE FORCE
[email protected] +263718384192