增加servo文件夹

This commit is contained in:
myperworld committed 2025-12-07 17:29:00 +08:00
1 parent d78c65dc8e
commit cc9de2f90b
9 files changed
+157

No files matched your search

+2
View File
@@ -24,6 +24,8 @@ B站演示地址:https://space.bilibili.com/25336365
修改的地方挺多的不罗列了,代码增加了很多备注。 修改的地方挺多的不罗列了,代码增加了很多备注。
servo 文件夹是用于写入舵机初始化程序
2025-08-11增加开机自平衡站立,简化控制,通过 esp32 遥控器直接控制,无需配网。 2025-08-11增加开机自平衡站立,简化控制,通过 esp32 遥控器直接控制,无需配网。
2025-08-16对几种运动中倒地的极限状态进行优化,实现自平衡起身。 2025-08-16对几种运动中倒地的极限状态进行优化,实现自平衡起身。
+5
View File
@@ -0,0 +1,5 @@
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
+10
View File
@@ -0,0 +1,10 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"platformio.platformio-ide"
],
"unwantedRecommendations": [
"ms-vscode.cpptools-extension-pack"
]
}
+5
View File
@@ -0,0 +1,5 @@
{
"files.associations": {
"*.tcc": "cpp"
}
}
+37
View File
@@ -0,0 +1,37 @@
This directory is intended for project header files.
A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.
```src/main.c
#include "header.h"
int main (void)
{
...
}
```
Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.
In C, the convention is to give header files names that end with `.h'.
Read more about using header files in official GCC documentation:
* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
+46
View File
@@ -0,0 +1,46 @@
This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into the executable file.
The source code of each library should be placed in a separate directory
("lib/your_library_name/[Code]").
For example, see the structure of the following example libraries `Foo` and `Bar`:
|--lib
| |
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| | |- library.json (optional. for custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| |
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |
| |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c
Example contents of `src/main.c` using Foo and Bar:
```
#include <Foo.h>
#include <Bar.h>
int main (void)
{
...
}
```
The PlatformIO Library Dependency Finder will find automatically dependent
libraries by scanning project source files.
More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html
+14
View File
@@ -0,0 +1,14 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
+38
View File
@@ -0,0 +1,38 @@
#include <Arduino.h>
void onReceiveFunction(void) {
while (Serial.available() > 0) {
char data = Serial.read();
Serial2.write(data); // 将数据发送到舵机
}
}
void onReceiveFunction2(void) {
while (Serial2.available() > 0) {
char data = Serial2.read();
Serial.write(data); // 将数据发送到串口
}
}
//Serial、Serial1、Serial2 分别对应了 UART0、UART1 和 UART2。
void setup() {
//串口0初始化
Serial.begin(1000000); //usb串口
Serial2.begin(1000000); //舵机串口
Serial.onReceive(onReceiveFunction); //为串口设置回调函数
Serial2.onReceive(onReceiveFunction2); //为串口设置回调函数
}
void loop() {
// 从串口读取数据
if (Serial.available())
{
char data = Serial.read();
// 将数据发送到 舵机
Serial2.write(data);
}
// 从舵机读取输入数据
if (Serial2.available())
{
char data = Serial2.read();
// 将数据发送到 UART0
Serial.write(data);
}
}
Binary file not shown.