Skip to content

Commit

Permalink
Create redsiren.ino
Browse files Browse the repository at this point in the history
  • Loading branch information
kiaralee committed Sep 5, 2023
1 parent 36ab518 commit 5623c77
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions redsiren.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#include <TinyGPSPlus.h>
#include <SoftwareSerial.h>

const int RXPin = 4, TXPin = 3;

const int button = 9;
const uint32_t GPSBaud = 9600; //Default baud of NEO-6M is 9600
float lt = 48.4652; // Random long starting point
float lg = 123.308; // Random lat starting point



bool buttonPressed = false;


TinyGPSPlus gps; // the TinyGPS++ object
SoftwareSerial ss(RXPin, TXPin); // the serial interface to the GPS device

SoftwareSerial btSerial(10, 11); // set serial RX & TX to pins 10 & 11 respectively
String bt_rx; //set up recieved string variable

void setup() {
Serial.begin(9600);
ss.begin(GPSBaud);
btSerial.begin(9600);

Serial.println(F("Arduino - GPS module"));
}

void loop() {
//btSerial.println("Hudson is the best"); //Print message over terminal

// read from button
if(digitalRead(button)){
buttonPressed = !buttonPressed;
delay(1000);
}

// First checks if GPS is plif the button hasn't been pressed, then continue checking for button
/*
if (millis() > 5000 && gps.charsProcessed() < 10) {
Serial.println(F("No GPS data received: check wiring"));
}
*/
if(buttonPressed){

// If the GPS has valid longitude and latitude numbers, update them if possible
// Else, print predetermined lat and long
if(gps.location.isValid()){
if((gps.location.lat() < (lt - 0.05)) || gps.location.lng() > (lg + 0.05)){
printFloat(gps.location.lat(), gps.location.isValid(), 11, 6);
printFloat(gps.location.lng(), gps.location.isValid(), 12, 6);
}
} else {

btSerial.println ("Emergancy, Help Wanted at this Location");

btSerial.print("Coordinates: ");
btSerial.print(lt); //lat of UVIC
btSerial.print(", ");
btSerial.println(lg); //long of UVIC

}
smartDelay(1000);
}

0 comments on commit 5623c77

Please sign in to comment.