fix sender module final
This commit is contained in:
parent
6e39ea1fe4
commit
a9227420e8
@ -2,24 +2,14 @@
|
||||
#include <SD.h>
|
||||
#include <Servo.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 SERVO_A_PIN = 3;
|
||||
const int SERVO_A_PIN = 7;
|
||||
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
|
||||
RF24 radio(NRF_CE_PIN, NRF_CS_PIN);
|
||||
File dataFile;
|
||||
Servo A;
|
||||
Servo B;
|
||||
|
||||
// Flight stages
|
||||
enum FlightStage
|
||||
@ -38,16 +28,16 @@ void setup()
|
||||
// Initialize Serial
|
||||
Serial.begin(115200);
|
||||
|
||||
while (!Serial)
|
||||
;
|
||||
Serial.println("# Welcome to CobraV2 operating system for rocket");
|
||||
//while (!Serial)
|
||||
// ;
|
||||
//Serial.println("# Welcome to CobraV2");
|
||||
delay(1000);
|
||||
|
||||
pinMode(BUZZER_PIN, OUTPUT);
|
||||
digitalWrite(BUZZER_PIN, LOW);
|
||||
|
||||
A.attach(5); // attaches the servo on pin 9 to the servo object
|
||||
B.attach(6);
|
||||
A.attach(SERVO_A_PIN);
|
||||
A.write(80);
|
||||
// Start with preflight stage
|
||||
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
|
||||
//if (!SD.begin(CHIP_SELECT))
|
||||
//{
|
||||
@ -167,7 +149,12 @@ void arm_stage()
|
||||
if (IMU.accelerationAvailable())
|
||||
{
|
||||
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(" ");
|
||||
@ -243,20 +230,10 @@ void descent_stage()
|
||||
Serial.println("# DESCENT stage");
|
||||
//File dataFile = SD.open("data.txt", FILE_WRITE);
|
||||
//dataFile.println("# DESCENT stage");
|
||||
for (int pos = 0; pos <= 150; pos += 1)
|
||||
{
|
||||
// in steps of 1 degree
|
||||
A.write(pos);
|
||||
delay(1);
|
||||
Serial.println(pos);
|
||||
}
|
||||
A.write(80);
|
||||
delay(1000);
|
||||
A.write(180);
|
||||
|
||||
for (int pos = 90; pos >= 0; pos -= 1)
|
||||
{
|
||||
B.write(pos);
|
||||
delay(1);
|
||||
Serial.println(pos);
|
||||
}
|
||||
Serial.println("# Parachute deployed");
|
||||
|
||||
unsigned long StartTime = millis();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user