PHY-S-12-DOCUMENTATION

View the Project on GitHub tahafarhan1/PHY-S-12-DOCUMENTATION

25 July 2019

09: Electronic Output Devices

by

Using a DC motor

In this lab class, our assignment was to build a circuit with an output that we had previously used before. I chose to use a DC motor as my output but for it to turn on I had a light sensor connected and a certain threshold had to be crossed for it to turn on. In this circuit, I used a DC motor, a light sensor (photo resistor), a MOSFET transistor, a 10k ohm resistor and an Arduino nano board.

circuit

Before I added the DC motor component I tested out my circuit with an LED and after I got it to work I got about to working on adding the motor. To do this, I had to connect a MOSFET. The motor was connected to the drain, source to 5 volts and ground to Analog pin 2 on the Arduino. After this was done, I had to write my code to get it to work.

int photoPin = A4;
int photoValue = 0;
int motorPin = 2;
 
 void setup() {
  // initialize digital pin LED_BUILTIN as an output.
    Serial.begin(9600);
 pinMode(2,OUTPUT);
} 

// the loop function runs over and over again forever
void loop() {
  int photoValue = analogRead(photoPin);
  Serial.println(photoValue);
  if (photoValue > 400) { digitalWrite(2,HIGH);}
  else {digitalWrite(2,LOW) ;}
delay(500);} 

I had to add a delay because the value exceeded 400 momentarily so the DC motor did not turn on properly. The next video shows the circuit in action with the DC motor working. I increased the light intensity on the sensor by pointing a flashlight right on it.

tags: