first steps for drone firmware

This commit is contained in:
2025-01-27 17:19:19 +01:00
parent a82bd8beb5
commit f3d04a368d
2 changed files with 25 additions and 2 deletions

9
src/drone/conf.h Normal file
View File

@@ -0,0 +1,9 @@
#define MOTOR1 D0
#define MOTOR2 D1
#define MOTOR3 D2
#define MOTOR4 D3
#define PWMFREQ 50 //every 20ms
#define PWMRESOLUTION 16
#define BNOINTERRUPTSIG D6
#define BNOI2CADRESS 0x4b
//https://docs.arduino.cc/language-reference/en/structure/further-syntax/define/

View File

@@ -1,4 +1,4 @@
#include <FastLED.h> #include "conf.h"
#include <Adafruit_BNO08x.h> #include <Adafruit_BNO08x.h>
#include <sh2.h> #include <sh2.h>
#include <sh2_SensorValue.h> #include <sh2_SensorValue.h>
@@ -8,7 +8,11 @@
#include <shtp.h> #include <shtp.h>
void setup() { void setup() {
// put your setup code here, to run once: // Setup all ESC
ledcAttach(MOTOR1, PWMFREQ, PWMRESOLUTION);
ledcAttach(MOTOR2, PWMFREQ, PWMRESOLUTION);
ledcAttach(MOTOR3, PWMFREQ, PWMRESOLUTION);
ledcAttach(MOTOR4, PWMFREQ, PWMRESOLUTION);
} }
@@ -16,3 +20,13 @@ void loop() {
// put your main code here, to run repeatedly: // put your main code here, to run repeatedly:
} }
void calibrateESC() {
ledcWrite(MOTOR1, 1100);
ledcWrite(MOTOR2, 1100);
ledcWrite(MOTOR3, 1100);
ledcWrite(MOTOR4, 1100);
}
//https://randomnerdtutorials.com/esp32-pwm-arduino-ide/