Advertisement
kartonman

Servo Set Initial Position

Jun 23rd, 2023 (edited)
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. /*This sketch, created by Gary Granai, steamtraininfo.com, is free to use for your personal use as long as these credits remain in the sketch. It may not be used or reproduced for commercial purposes.
  2. To use servos in slow moving switch machines, go to https://steamtraininfo.com/for-modelers/arduino-projects/arduino-diy-switch-machines
  3. To use servos in level crossings go to https://steamtraininfo.com/level-crossings/grade-crossing-circuit*/
  4.  
  5. #include <Servo.h> // compiler directive to get the servo library   Servo myservo;  // create a servo object // from here on use the variable "myservo" to // access and control the servo object void setup() // the setup function is run once at boot {   myservo.attach(9);  // attaches to the servo on pin 9   myservo.write(90); // set the servo shaft at 90 degrees }   // the loop function runs after setup until the board is powered off  void loop() {   // do nothing }
Tags: servo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement