You are on page 1of 5

STEM 4.

2
Arduino Motors
Types of Motors:
1. DC Motors (Direct Current)
- for something to spin
- does not need precision
- can run freely in both directions
- very difficult to control when it comes to speed and precision
- two wires: power, ground
- ex. fans inside a computer or phone
2. Stepper Motor
- can be found in electronics
- high precision is important
- full rotation
- rotation is divided into equally big steps and you can control the motor to stop at each
of these steps
- ex. printers, scanners
3. Servo Motor
- often used in robotics and toys
- can rotate to 180 degrees with precision
- has three wires: power, ground, and for the control signal
Continuous Servo
- similar to a DC motor
- can spin in both directions, but not as fast
- can control both speed and direction without the use of transistors
Code Explanation:
1. Servo (variable)
- creates a servo object named by the given variable name
2. (variable).attach (pin#)
- attaches the servo (variable) to the digital pin connected
3. (variable).write (degrees)
- makes standard servo shaft rotate to the position angle specified
- from 0 – 180
Code:
#include <servo.h>

Servo serva;
int pin = A1;
int val;

void setup () {
serva.attach (6);
}

void loop () {
val = analogRead (pin);
val = map (val, 0, 1023, 0, 180);
serva.write (val);
delay (15);
}
Functions
- a block of organized, reusable code
- used to perform a single, related action
Other Arduino Components:
1. RGB LED Lights
- consists of three different led’s
- may be able to obtain other colors by mixing
- 3 are connected to different digital pins while the other 1 is connected to ground
2. Slide Switch
- mechanical switches using a slider that moves
- used for controlling current flow in small projects
Code:
void setup () {
pinMode (10, OUTPUT);
pinMode (11, INPUT);
}

void loop () {
int state = digitalRead (11);
if (state == HIGH) {
digitalWrite (10, HIGH);
}

else; {
digitalWrite (10, LOW);
}
}
3. Capacitors
- releases electrical energy in a circuit
- widely used for blocking direct current while allowing alternating current to pass
4. Diode
- allows electricity to flow in only one direction
- used to convert AC to DC and to filter out the signal in radios
- used to protect electronics, light up homes, and send remote-control signals
5. Photoresistor
- also known as LDR (Light-dependent Resistors)
- sensor in which its resistance changes based on the amount of light it senses
- used as light sensors and applications of LDR mainly include alarm clocks, street
lights, light intensity meters, burglar alarm circuits
7. Phototransistor
- used extensively to detect light pulses and convert them into digital electrical signals
- operated by light rather than electric current
8. Infrared (IR) Sensor
- an electronic device that measures and detects infrared radiation in its surrounding
environment
- used in motion detectors
9. Flex Sensor
- bend sensor
- sensor that measures the amount of deflection or bending
- common in different technological products such as automotive and industrial controls,
computer peripherals, joysticks, and measuring devices
10. Force Sensor
- another term for “load cell” or “weight sensor”
- used to measure compression, force, strain, and load
11. Ultrasonic Distance Sensor
- electronic device that measures the distance of a target object by emitting ultrasonic
sound waves and converts the reflected sound into an electrical signal
- used primarily as proximity sensors
- can be found in automobile self-parking technology and anti-collision safety systems
12. Passive Infrared (PIR) Sensor
- allows you to sense motion
- always used to detect whether a human has moved in or out of the sensors range
- detects body heat by looking for changes in temperature
13. Gas Sensor
- detects the presence or concentration of gases in the atmosphere
- commonly used to detect toxic or explosive gasses
- measures gas concentration
14. 7 Segment Display
- form of electronic display
- for displaying decimal numerals that is an alternative to the more complex dot matrix
displays
- widely used in digital clocks, electronic meters, basic calculators, and other electronic
devices that displays numerical information
- 7 wires for each line, 1 for the dot, 1 for the power, and the other one for the ground
15. 16 x 2 LCD
- can display 16 characters per line
- has two lines
- electronic display module used in an extensive range of applications like various
circuits and devices like mobile phones, calculators, computers, TV sets, etc.

You might also like