forked from arduino-libraries/Arduino_PortentaMachineControl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEncoders.ino
43 lines (38 loc) · 1.22 KB
/
Encoders.ino
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
41
42
43
/*
* Portenta Machine Control - Encoder Read Example
*
* This sketch shows the functionality of the encoders on the Machine Control.
* It demonstrates how to periodically read and interpret the values from the two encoder channels.
*
* Circuit:
* - Portenta H7
* - Portenta Machine Control
*
* This example code is in the public domain.
* Copyright (c) 2024 Arduino
* SPDX-License-Identifier: MPL-2.0
*/
#include <Arduino_PortentaMachineControl.h>
void setup() {
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect.
}
}
void loop() {
Serial.print("Encoder 0 State: ");
Serial.println(MachineControl_Encoders.getCurrentState(0),BIN);
Serial.print("Encoder 0 Pulses: ");
Serial.println(MachineControl_Encoders.getPulses(0));
Serial.print("Encoder 0 Revolutions: ");
Serial.println(MachineControl_Encoders.getRevolutions(0));
Serial.println();
Serial.print("Encoder 1 State: ");
Serial.println(MachineControl_Encoders.getCurrentState(1),BIN);
Serial.print("Encoder 1 Pulses: ");
Serial.println(MachineControl_Encoders.getPulses(1));
Serial.print("Encoder 1 Revolutions: ");
Serial.println(MachineControl_Encoders.getRevolutions(1));
Serial.println();
delay(25);
}