fabianmoronzirfas
8/3/2016 - 12:51 PM

basic_motor_controll.ino

/*
  Motor
  turning a motor clock then counter clock wise

  This example is part of the Fritzing Creator Kit: www.fritzing.org/creatorkit.
*/

int motor_turn_this_way=11;                    // motor direction one Pin
int motor_turn_that_way=10;                    // motor direction two Pin
int motor_speed=9;                // speed Pin

void setup(){
  pinMode(motor_turn_this_way,OUTPUT);        // pin A declared as OUTPUT
  pinMode(motor_turn_that_way,OUTPUT);        // pin B declared as OUTPUT
  pinMode(motor_speed, OUTPUT);

  digitalWrite(motor_turn_this_way,HIGH);     // motor direction one pin switched to HIGH (+5V)
  digitalWrite(motor_turn_that_way,LOW);      // motor direction two pin switched to LOW  (GND)
}

void loop(){
  /*0 - 255*/
  analogWrite(motor_speed, 100 );

  delay(1000);

  analogWrite(motor_speed, 0);

  delay(5000);
}