Mini proiect (12) - Servomotor

Servomotor

Azi am la teste un servomotor simplu cu trei pini VCC, GND si pinul de comanda. Am folosit pinul 2 de pe placa Arduino, care are și PWM. Pentru acest servomotor a trebui sa-i conectez o sursa de tensiune de minim 6V pentru că motorașul consumă mai mult curent decât curentul furnizat de placa Arduino. GND-ul l-am conectat comun pentru a avea aceeași masă pentru Arduino și servomotor. În circuit am folosit un acumulator de 7.2V si 1600 mAh, o placă distribuitor cu întrerupător de la o dronă mai veche. Servomotorul s-a încălzit un pic și sincer nu știu dacă e normal sau este acumulatorul un pic prea puternic. Funcționează destul de bine, și o să încerc să mai conectez încă un servomotor să observ dacă accumulatorul poate să furnizeze suficient curent pentru mai multe servomotoare.

Documentatie proiect

Componente


Schema electronica/sistem


Cod de test

L-am programat să se învârtă 180 grade într-un sens și invers. Merge brici :D

//Servos
#include "servo.h"
Servo myservo;  // create servo object to control a servo 
int pos = 0;    // variable to store the servo position
void setup() {
  Serial.begin(9600);

  myservo.attach(2);  //the pin for the servo control

  Serial.println("Servo motor v1 "); 
}

void loop() {

  for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(50);                       // waits 50ms for the servo to reach the position
  }
  for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(50);                       // waits 50ms for the servo to reach the position
  }
}
O seară bună tuturor !