Building a simple Motor Circuit. I think the photos are pretty straightforward to follow. The resistor featured in this simple project is a 10 ohm resistor and the motor is a 7.5v DC motor with max output current of 100ma or .1Amps....That being said, the 10 ohm resistor isn't a necessity but it will increase the life expectancy of your motor. Also, if you've never worked with a bread board before, look at photo 2. The yellow arrow/ line denotes the horizontal bars; power runs horizontally in these bars. The vertical bars follow the same set of rules except they all run vertically and independently of one another. See the code to make it run. Motor Code: /*A simple snipet of code that runs a DC motor in one direction and then in the opposite direction.
You should be familiar with the concept of Pulse Width Modulation or PWM as it is used to control the speed*/
int dirA = 12; //designtaes variable dirA as pin 12
int pwm_A = 3; //designates pwm_A as pin 3
int i = 255; //Used for speed control
int j = -255;//Used to reverse direction at full speed
void setup()
{
pinMode(dirA, OUTPUT); //Designates dirA as an OUTPUT
pinMode(pwm_A, OUTPUT); //Designates pwm_A (pin 3) as the PWM pin
}
void loop()
{
digitalWrite(dirA, HIGH);//Turns power on to dir_A
analogWrite(pwm_A, i);//Using pwm_A, it determines which speed to run it at
delay(6000);//Runs the motor for 6 sec at this speed
digitalWrite(dirA, LOW);//Turns power off
analogWrite(pwm_A, 0);//Turns the wave reading to 0
delay(2000);//Keeps it off for 2 sec
//Reverses the direction of the motor by using "j" instead of i
digitalWrite(dirA, HIGH);
analogWrite(pwm_A, j);
delay(3000);
digitalWrite(dirA, LOW);
analogWrite(pwm_A, 0);
delay(3000);
}
















