Skip to content

Instantly share code, notes, and snippets.

@e-Gizmo
Created November 16, 2018 07:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save e-Gizmo/8d2a3c03e999bf9c6ff82ba5d80c3f1d to your computer and use it in GitHub Desktop.
Save e-Gizmo/8d2a3c03e999bf9c6ff82ba5d80c3f1d to your computer and use it in GitHub Desktop.
This is one of an examples code from16Channel servo controller library. Add the eGizmo_16ChannelServo libary.
/*
ServoSweep Sample sketch
An example code for ServoSweep.
Use SoftwareSerial pin 2 (RX) and 3 (TX).
ServoDriver to gizDuino
TX --> pin2 (RX)
RX --> pin3 (TX)
GND --> GND
PWR --> 5V supply*
Note*: you can use 5V supply on the gizduino required
only 1-2 servo like SG-90.
If 3 or more servo SG-90 to MG995 etc., with high
current/torque,please use SoftStarter to limit/
control the current on each servo motors
and seperate the supply.
SoftStarter kit : (Optional) http://goo.gl/Ak9x17
Adaptor: (Optional) http://goo.gl/AbxLuQ
Codes by
e-Gizmo Mechatronix Central
November 2, 2018
http://www.e-gizmo.net/oc
*/
#include "eGizmo_16channelServo.h"
//SoftwareSerial is already included
SoftwareSerial softSerial(2,3);
eGizmo_16channelServo servoDriver(&softSerial);
//To use hardware Serial pins, use this instead
//eGizmo_16channelServo servoDriver(&Serial);
int position = 10;
void setup() {
// put your setup code here, to run once
servoDriver.begin(9600);
}//Setup
void loop() {
for(position = 10; position < 160; position += 1) // shaft position goes from 10 to 160 degrees
{ // in steps of 1 degree
servoDriver.moveServo(2,position); // tell servo channel 2 to go to position in value
delay(15); // waits 15ms for the servo to reach the position
}
for(position = 160; position >= 10; position -= 1)// position goes from 160 degrees to 10.
{
servoDriver.moveServo(2,position); // tell servo channel 2 to go to position in value
delay(15); // waits 15ms for the servo to reach the position
}
}//Loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment