Chat
Welcome to Flux
Treat Flux like your intern. Tell it what you'd like to build and it'll get to work. You can also ask it questions, brainstorm ideas, and teach it your preferences. Learn More
Ready.
#include
#include
// Define el pin RX al que está conectado el TX del GPS
// y el pin TX al que está conectado el RX del GPS
static const int RXPin = 17, TXPin = 16;
static const uint32_t GPSBaud = 9600;
// El objeto TinyGPS++ que se encarga de analizar los datos del GPS
TinyGPSPlus gps;
// El objeto SoftwareSerial se encarga de la comunicación serie
SoftwareSerial ss(RXPin, TXPin);
void setup() {
Serial.begin(9600);
ss.begin(GPSBaud);
Serial.println(F("GPS iniciado"));
}
void loop() {
// Esta línea se encarga de leer los datos del GPS
while (ss.available() > 0) {
gps.encode(ss.read());
}
// Cada 5 segundos, imprime la latitud y la longitud
if (millis() > 5000 && gps.location.isValid()) {
Serial.print("Latitud:");
Serial.println(gps.location.lat(), 6);
Serial.print("Longitud:");
Serial.println(gps.location.lng(), 6);
}
}
Cpp
#include #include // Define el pin RX al que está conectado el TX del GPS // y el pin TX al que está conectado el RX del GPS static const int RXPin = 17, TXPin = 16; static const uint32_t GPSBaud = 9600; // El objeto TinyGPS++ que se encarga de analizar los datos del GPS TinyGPSPlus gps; // El objeto SoftwareSerial se encarga de la comunicación serie SoftwareSerial ss(RXPin, TXPin); void setup() { Serial.begin(9600); ss.begin(GPSBaud); Serial.println(F("GPS iniciado")); } void loop() { // Esta línea se encarga de leer los datos del GPS while (ss.available() > 0) { gps.encode(ss.read()); } // Cada 5 segundos, comprueba si la ubicación es válida if (millis() > 5000) { if (gps.location.isValid()) { Serial.print("Latitud:"); Serial.println(gps.location.lat(), 6); Serial.print("Longitud:"); Serial.println(gps.location.lng(), 6); } else { Serial.println("Sin señal"); } } }
Reviews
Properties
Properties describe core aspects of the project.
Pricing & Availability
Distributor | Qty 1 |
|---|---|
Digi-Key | $30.60 |
Mouser | $30.60 |
Assets
No assets added.
Controls
Welcome 👋
Flux helps you build PCBs faster with an AI teammate!
Create your account to collaborate, stay updated, fork your own version, and get instant answers from our AI agent.
angelgabrielgarciasuarez
copilot