Created
July 21, 2014 16:09
-
-
Save esdrasdutra/98646dc2384fbe3dfcdb to your computer and use it in GitHub Desktop.
código para testes com o servo motor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Criado por Ronilson Santos em 17/07/2014 | |
* Testes realizados com sucesso. | |
*/ | |
#include <Servo.h> //Inclui a bibioteca utilizada pelo servo motor. | |
const int ServoMotorPin = 3; //Setando o servo motor da porta 3 (PWM) | |
Servo MeuServoMotor; //Criando um objeto da classe Servo | |
void setup() | |
{ | |
Serial.begin(9600); //Inicia a comunicação com a Porta Serial | |
MeuServoMotor.attach(ServoMotorPin); //Associando o pino ao objeto da classe Servo | |
} | |
void loop() | |
{ | |
ServoMotorFrente(); | |
delay(5000); | |
ServoMotorDireita(); | |
delay(5000); | |
ServoMotorFrente(); | |
delay(5000); | |
ServoMotorEsquerda(); | |
delay(5000); | |
} | |
void ServoMotorFrente() //Volta o Servo Motor para frente | |
{ | |
MeuServoMotor.write(90); //Servo voltado para a frente | |
Serial.println("Servo Motor apontando para a Frente"); | |
} | |
void ServoMotorDireita() //Volta o Servo Motor para Direita | |
{ | |
MeuServoMotor.write(5); //Servo voltado para a Direita | |
Serial.println("Servo Motor apontando para a Direita"); | |
} | |
void ServoMotorEsquerda() //Volta o Servo Motor para Esquerda | |
{ | |
MeuServoMotor.write(179); //Servo voltado para a Esquerda | |
Serial.println("Servo Motor apontando para a Esquerda"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment