-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstepper_test.cpp
More file actions
40 lines (33 loc) · 867 Bytes
/
Copy pathstepper_test.cpp
File metadata and controls
40 lines (33 loc) · 867 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include "pico/stdlib.h"
#include "Stepper.h"
const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
// for your motor
// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 0, 1, 2, 3);
void setup() {
// set the speed at 60 rpm:
myStepper.setSpeed(60);
// initialize the serial port:
// Serial.begin(9600);
}
void loop() {
// step one revolution in one direction:
// Serial.println("clockwise");
myStepper.step(stepsPerRevolution);
sleep_ms(500);
// step one revolution in the other direction:
// Serial.println("counterclockwise");
myStepper.step(-stepsPerRevolution);
sleep_ms(500);
}
int main() {
setup();
while (true) {
loop();
}
}