surfnm:
Hi kimjunsuk
You might take a look at the Udemy drone class offerings to see if any can augment your class work.
Udemy Drone Classes
What book(s) are you using and do you have any Nano 33 IoT drone code to share?
The recommendations are appreciated, but if possible, I don't want to spend money on lectures because i already spent too much money to solve some problem while i've made drone.
This is my code. i use Blynk, IR laser measuring sensor, and accellometor sensor library.
#include <Arduino_LSM6DS3.h>
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <WiFiNINA.h>
#include <BlynkSimpleWiFiNINA.h>
#include <Arduino_LSM6DS3.h>
#include "Adafruit_VL53L0X.h"
Adafruit_VL53L0X lox = Adafruit_VL53L0X();
char auth[] = "---------------------------------------------";
char ssid[] = "-------------";
char pass[] = "-------------------";
int ml=4;
int mr=5;
int fl=3;
int fr=6;
int bl=9;
int br=10;
int c=75;
int dis;
double D=0;
double i=0;
double flspd=0;
double frspd=0;
double blspd=0;
double brspd=0;
double mlspd=0;
double mrspd=0;
void altitude();
void attitude();
void setup() {
Blynk.begin(auth, ssid, pass);
pinMode(fl,OUTPUT);
pinMode(fr,OUTPUT);
pinMode(bl,OUTPUT);
pinMode(br,OUTPUT);
pinMode(ml,OUTPUT);
pinMode(mr,OUTPUT);
Serial.begin(9600);
if (!IMU.begin()) {
Serial.println("Failed to initialize IMU!");
while (1);
}
if (!lox.begin()) {
Serial.println(F("Failed to boot VL53L0X"));
while(1);
}
}
BLYNK_WRITE(V0){
dis=param.asInt();
}
BLYNK_WRITE(V1){
int cx=param[0].asInt();
int cy=param[1].asInt();
if(flspd+cx-cy>=0&&flspd+cx-cy<=255){
flspd=flspd+cx-cy;
}
if(frspd-cx-cy>=0&&frspd-cx-cy<=255){
frspd=frspd-cx-cy;
}
if(blspd+cx+cy>=0&&blspd+cx+cy<=255){
blspd=blspd+cx+cy;
}
if(brspd-cx+cy>=0&&brspd-cx+cy<=255){
brspd=brspd-cx+cy;
}
if(mlspd+cx>=0&&mlspd+cx<=255){
mlspd=mlspd+cx;
}
if(mrspd-cx>=0&&mrspd-cx<=255){
mrspd=mrspd-cx;
}
}
void loop() {
Blynk.run();
altitude();
attitude();
analogWrite(ml,mlspd);
analogWrite(mr,mrspd);
analogWrite(fl,flspd);
analogWrite(fr,frspd);
analogWrite(bl,blspd);
analogWrite(br,brspd);
}
void altitude(){//altitude handling
VL53L0X_RangingMeasurementData_t measure;
lox.rangingTest(&measure, false);
if (measure.RangeStatus != 4) {
Serial.print("Distance (mm): ");
Serial.println(measure.RangeMilliMeter);
D=((dis-measure.RangeMilliMeter/10)(dis-measure.RangeMilliMeter/10)(dis-measure.RangeMilliMeter/10))/54;
if((i+D)<=255&&(i+D)>=0){
i+=D;
}
else if((i+D)<0){
i+=0;
}
else if((i+D)>255){
i+=(int)D%255;
}
}
else {
}
}
void attitude(){//attitude control
float x, y, z;
if (IMU.accelerationAvailable()) {
IMU.readAcceleration(y, x, z);
if(i+xxxc-yyyc>=0&&i+xxxc-yyyc<=255){
frspd=i+xxxc-yyyc;
}
if(i-xxxc-yyyc>=0&&i-xxxc-yyyc<=255){
flspd=i-xxxc-yyyc;
}
if(i+xxxc+yyyc>=0&&i+xxxc+yyyc<=255){
brspd=i+xxxc+yyyc;
}
if(i-xxxc+yyyc>=0&&i-xxxc+yyyc<=255){
blspd=i-xxxc+yyyc;
}
if(i+xxxc>=0&&i+xxxc<=255){
mrspd=i+xxxc;
}
if(i-xxxc>=0&&i-xxxc<=255){
mlspd=i-xxxc;
}
}
}
Thank you 