Created
March 15, 2022 19:52
-
-
Save jaxlo/02acaf43fbceff9e7c9b2d72f0cdc1e7 to your computer and use it in GitHub Desktop.
rocket_electronics.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <TinyGPSPlus.h> | |
#include <SoftwareSerial.h> | |
// SD Logger | |
// ESP32 pin - wire color - SD card pin | |
//--------------------------------- | |
// P4 - green - GRN | |
// P0 - yellow - RXI | |
// P2 - orange - TX0 | |
// P15 - brown - BLK | |
// Onboard LED | |
#define ONBOARD_LED 2 | |
// GPS | |
TinyGPSPlus gps; | |
static const int gpsRXPin = 36, gpsTXPin = 39; | |
static const uint32_t GPSBaud = 9600; | |
SoftwareSerial ssGPS(gpsRXPin, gpsTXPin); | |
void setup() { | |
// Setup for USB serial monitor | |
Serial.begin(9600); | |
// GPS | |
ssGPS.begin(GPSBaud); | |
// Onboard Blue LED blinks after all info is gathered | |
// Setup blue LED | |
pinMode(ONBOARD_LED,OUTPUT); | |
Serial.println("Setup Complete"); | |
blink(3, 200); | |
} | |
void loop() { | |
// GPS | |
while (ssGPS.available() > 0) { | |
gps.encode(ssGPS.read()); | |
} | |
if (Serial.available()) { | |
Serial.println(gps.altitude.meters()); // I can't seem to get anything from the GPS. Maybe mine is broken? | |
} | |
blink(1, 30); // The second number indicated the wait time. Feel free to lower | |
} | |
void blink(int times, int delayMS) { | |
// Blink the blue LED to indicate that the code is running properly | |
for (int i=0; i < times; i++) { | |
digitalWrite(ONBOARD_LED,HIGH); | |
delay(delayMS); | |
digitalWrite(ONBOARD_LED,LOW); | |
delay(delayMS); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment