-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathSimple.ino
72 lines (62 loc) · 2.88 KB
/
Simple.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
* Simple.cpp
*
* Shows smooth linear movement from one servo position to another.
* This example does not use interrupts and should therefore run on any platform where the Arduino Servo library is available.
*
* Copyright (C) 2019-2022 Armin Joachimsmeyer
*
* This file is part of ServoEasing https://github.com/ArminJo/ServoEasing.
*
* ServoEasing is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
*/
#include <Arduino.h>
#include "ServoEasing.hpp"
#include "PinDefinitionsAndMore.h"
/*
* Pin mapping table for different platforms - used by all examples
*
* Platform Servo1 Servo2 Servo3 Analog Core/Pin schema
* -------------------------------------------------------------------------------
* (Mega)AVR + SAMD 9 10 11 A0
* 2560 46 45 44 A0
* ATtiny3217 20|PA3 0|PA4 1|PA5 2|PA6 MegaTinyCore
* ESP8266 14|D5 12|D6 13|D7 0
* ESP32 5 18 19 A0
* BluePill PB7 PB8 PB9 PA0
* APOLLO3 11 12 13 A3
* RP2040 6|GPIO18 7|GPIO19 8|GPIO20
*/
ServoEasing Servo1;
void setup() {
Serial.begin(115200);
while (!Serial)
; // Wait for Serial to become available. Is optimized away for some cores.
// Just to know which program is running on my Arduino
Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_SERVO_EASING));
/********************************************************
* Attach servo to pin and set servo to start position.
*******************************************************/
Serial.println(F("Attach servo at pin " STR(SERVO1_PIN)));
Servo1.attach(SERVO1_PIN, 45); // Attach pin and go to initial position of 45 degree
delay(500); // Wait for servo to reach start position.
}
void loop() {
Serial.println(F("Move to 135 degree with 40 degree per second blocking"));
Servo1.easeTo(135, 40); // Blocking call, runs on all platforms
Serial.println(F("Move to 45 degree with 40 degree per second blocking"));
Servo1.easeTo(45, 40); // Blocking call, runs on all platforms
delay(1000);
}