From a9227420e84ec91d0fe5274f3a6c57c05c42b4c7 Mon Sep 17 00:00:00 2001 From: shinya Date: Fri, 20 Jun 2025 16:21:22 +0200 Subject: [PATCH] fix sender module final --- sender_module_final/sender_module_final.ino | 53 ++++++--------------- 1 file changed, 15 insertions(+), 38 deletions(-) diff --git a/sender_module_final/sender_module_final.ino b/sender_module_final/sender_module_final.ino index 3545a8e..8de22fe 100644 --- a/sender_module_final/sender_module_final.ino +++ b/sender_module_final/sender_module_final.ino @@ -2,24 +2,14 @@ #include #include #include "Arduino_BMI270_BMM150.h" -#include -#include - -// 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();