RBE1001Lib
MotorSpinExample.ino
Go to the documentation of this file.
1 #include <Arduino.h>
2 #include <RBE1001Lib.h>
3 
4 // pin definitions https://wpiroboticsengineering.github.io/RBE1001Lib/RBE1001Lib_8h.html#define-members
5 const int buttonPin = BOOT_FLAG_PIN;
6 
9 bool upDown = false;
10 /*
11  * This is the standard setup function that is called when the ESP32 is rebooted
12  * It is used to initialize anything that needs to be done once.
13  */
14 void setup()
15 {
16  // This will initialize the Serial as 115200 for prints
17  Serial.begin(115200);
18 }
19 
20 /*
21  * The main loop for the program. The loop function is repeatedly called
22  * once the ESP32 is started.
23  */
24 void loop()
25 {
26  while (digitalRead(buttonPin))
27  {
28  } //wait for button press
29  left_motor.setSpeed(120);
30 
31  uint32_t startTime = millis();
32 
33  while (millis() - startTime < 5000) //run for 5 seconds
34  {
35  Serial.print(left_motor.getDegreesPerSecond());
36  Serial.print('\t');
37  Serial.print(left_motor.getEffortPercent());
38  Serial.print('\n');
39 
40  delay(20);
41  }
42 
43  left_motor.setSpeed(0);
44 }
LeftMotor left_motor
const int buttonPin
#define BOOT_FLAG_PIN
Definition: RBE1001Lib.h:12
void setSpeed(float newDegreesPerSecond)
Definition: Motor.cpp:295
bool upDown
void setup()
float getEffortPercent()
Definition: Motor.h:265
RightMotor right_motor
float getDegreesPerSecond()
Definition: Motor.cpp:551
void loop()