fix sender module final
This commit is contained in:
parent
6e39ea1fe4
commit
a9227420e8
@ -2,24 +2,14 @@
|
|||||||
#include <SD.h>
|
#include <SD.h>
|
||||||
#include <Servo.h>
|
#include <Servo.h>
|
||||||
#include "Arduino_BMI270_BMM150.h"
|
#include "Arduino_BMI270_BMM150.h"
|
||||||
#include <nRF24L01.h>
|
|
||||||
#include <RF24.h>
|
|
||||||
|
|
||||||
// Define pin numbers for modules
|
|
||||||
const byte address[6] = "00001";
|
|
||||||
|
|
||||||
const int BUZZER_PIN = 2;
|
const int BUZZER_PIN = 2;
|
||||||
const int SERVO_A_PIN = 3;
|
const int SERVO_A_PIN = 7;
|
||||||
const int CHIP_SELECT = 4;
|
const int CHIP_SELECT = 4;
|
||||||
const int SERVO_B_PIN = 5;
|
|
||||||
const int NRF_CS_PIN = 8;
|
|
||||||
const int NRF_CE_PIN = 9;
|
|
||||||
|
|
||||||
// Create objects for modules
|
// Create objects for modules
|
||||||
RF24 radio(NRF_CE_PIN, NRF_CS_PIN);
|
|
||||||
File dataFile;
|
File dataFile;
|
||||||
Servo A;
|
Servo A;
|
||||||
Servo B;
|
|
||||||
|
|
||||||
// Flight stages
|
// Flight stages
|
||||||
enum FlightStage
|
enum FlightStage
|
||||||
@ -38,16 +28,16 @@ void setup()
|
|||||||
// Initialize Serial
|
// Initialize Serial
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
|
||||||
while (!Serial)
|
//while (!Serial)
|
||||||
;
|
// ;
|
||||||
Serial.println("# Welcome to CobraV2 operating system for rocket");
|
//Serial.println("# Welcome to CobraV2");
|
||||||
delay(1000);
|
delay(1000);
|
||||||
|
|
||||||
pinMode(BUZZER_PIN, OUTPUT);
|
pinMode(BUZZER_PIN, OUTPUT);
|
||||||
digitalWrite(BUZZER_PIN, LOW);
|
digitalWrite(BUZZER_PIN, LOW);
|
||||||
|
|
||||||
A.attach(5); // attaches the servo on pin 9 to the servo object
|
A.attach(SERVO_A_PIN);
|
||||||
B.attach(6);
|
A.write(80);
|
||||||
// Start with preflight stage
|
// Start with preflight stage
|
||||||
current_stage = READY;
|
current_stage = READY;
|
||||||
|
|
||||||
@ -96,14 +86,6 @@ void ready_stage()
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Radio
|
|
||||||
// radio.begin();
|
|
||||||
// radio.openWritingPipe(address);
|
|
||||||
// radio.stopListening(); // Set module as transmitter
|
|
||||||
// const char msg[] = "# Radio connection activated";
|
|
||||||
// radio.write(&msg, sizeof(msg));
|
|
||||||
// Serial.println("# Success nRF24L01 init");
|
|
||||||
|
|
||||||
// SD card
|
// SD card
|
||||||
//if (!SD.begin(CHIP_SELECT))
|
//if (!SD.begin(CHIP_SELECT))
|
||||||
//{
|
//{
|
||||||
@ -167,7 +149,12 @@ void arm_stage()
|
|||||||
if (IMU.accelerationAvailable())
|
if (IMU.accelerationAvailable())
|
||||||
{
|
{
|
||||||
IMU.readAcceleration(x, y, z);
|
IMU.readAcceleration(x, y, z);
|
||||||
Serial.println(x);
|
Serial.print(x);
|
||||||
|
Serial.print(", ");
|
||||||
|
Serial.print(y);
|
||||||
|
Serial.print(", ");
|
||||||
|
Serial.println(z);
|
||||||
|
|
||||||
|
|
||||||
//dataFile.print(x);
|
//dataFile.print(x);
|
||||||
//dataFile.print(" ");
|
//dataFile.print(" ");
|
||||||
@ -243,20 +230,10 @@ void descent_stage()
|
|||||||
Serial.println("# DESCENT stage");
|
Serial.println("# DESCENT stage");
|
||||||
//File dataFile = SD.open("data.txt", FILE_WRITE);
|
//File dataFile = SD.open("data.txt", FILE_WRITE);
|
||||||
//dataFile.println("# DESCENT stage");
|
//dataFile.println("# DESCENT stage");
|
||||||
for (int pos = 0; pos <= 150; pos += 1)
|
A.write(80);
|
||||||
{
|
delay(1000);
|
||||||
// in steps of 1 degree
|
A.write(180);
|
||||||
A.write(pos);
|
|
||||||
delay(1);
|
|
||||||
Serial.println(pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int pos = 90; pos >= 0; pos -= 1)
|
|
||||||
{
|
|
||||||
B.write(pos);
|
|
||||||
delay(1);
|
|
||||||
Serial.println(pos);
|
|
||||||
}
|
|
||||||
Serial.println("# Parachute deployed");
|
Serial.println("# Parachute deployed");
|
||||||
|
|
||||||
unsigned long StartTime = millis();
|
unsigned long StartTime = millis();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user