Created
December 2, 2017 10:35
-
-
Save coding-yogi/41988b6928c5a32ac66a5c50af7d1035 to your computer and use it in GitHub Desktop.
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
package main | |
import ( | |
"fmt" | |
"gobot.io/x/gobot" | |
"gobot.io/x/gobot/drivers/gpio" | |
"gobot.io/x/gobot/platforms/dexter/gopigo3" | |
"gobot.io/x/gobot/platforms/raspi" | |
) | |
func main() { | |
r := raspi.NewAdaptor() | |
gpg3 := gopigo3.NewDriver(r) | |
stepper := gpio.NewStepperDriver(gpg3, [4]string{"7", "11", "13", "15"}, gpio.StepperModes.DualPhaseStepping, 2048) | |
work := func() { | |
//Move one complete rotation | |
stepper.SetSpeed(15) | |
//Move forward | |
if err := stepper.Move(2048); err != nil { | |
fmt.Println(err) | |
} | |
//Move backward | |
if err := stepper.Move(-2048); err != nil { | |
fmt.Println(err) | |
} | |
} | |
robot := gobot.NewRobot("stepperBot", | |
[]gobot.Connection{r}, | |
[]gobot.Device{gpg3, stepper}, | |
work, | |
) | |
robot.Start() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment