In our first task we need to start the servo motor to make the ship walk on the waves.
View the video to learn about how a servo motor works and how we connect it to the brain of Blue Elixir Board. Also we will look into how the code is synced with the servo motor and Arduino.
Here are the code snippets referring to the servo motor.
#include <Servo.h>//WE INCLUDE THE SERVO LIBRARY MADE BY ARDUINO
Servo myservo;
int pos =0;
void setup(){Serial.begin(9600);
myservo.attach(9); // THE SERVO MOTOR IS CONNECTED TO THE D9 PIN OF ARDUINO}
void loop(){myservo.write(180);//SERVO MOTOR MOVES TO THE 180 DEGREE ANGLEdelay(1000); // Delay of 1 seconds between measurementsmyservo.write(90);//SERVO MOTOR MOVES TO THE 90 DEGREE ANGLEdelay(1000);
}
Here are the code snippets referring to the servo motor.