Raquel Gallego

Output Devices

MOTORS.

1_Design a new PCB to be able to controlled a motor.

We need a MOSFET ( transistor) to be able to apply a small current and the transistor will transform this small current into a value enough to move the motor.

_Schematic board_helloMotor

File: Schematic file.sch

_Board_ HelloMotor

File: Board file.brd

Milling the board

Files: Hello Motor.ps,Hello Motor.png

CODE

/*
  Hello Motor
  Applying a PWM to control how the motor moves.
 */

//Global variable
int motorspeed=0;



void setup() {                
  // initialize the digital pin as an output.
  // Pin 8 has an LED connected on most Arduino boards:
  pinMode(8, OUTPUT);
 
}

void loop() 
{
  int m;
  int entrada;
  
  analogWrite(2, motorspeed);
  
  // reading the digital value of pin number 7
  entrada = digitalRead(7); 
  
  // If we pressed the bottom increase the PWM value
  if (entrada == HIGH) 
  {
    motorspeed = motorspeed+10;
    if (motorspeed>255)
      motorspeed=0;
    delay (50);
  }
}

OSCILLOSCOPE TEST

 

VIDEO MOTOR RUNNING

 

 

 

Classes: