#arduino just gives up after starting the program
23 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
!f
#include <EEPROM.h>
#include <SoftwareSerial.h>
#include <TinyGPS++.h>
// definição de pinos
int RXPin = 2;
int TXPin = 3;
int address = 0;
int GPSBaud = 9600;
TinyGPSPlus gps;
SoftwareSerial gpsSerial(RXPin, TXPin);
void setup() {
Serial.println("test");
Serial.begin(9600);
pinMode(4, INPUT);
// iniciates serial port
gpsSerial.begin(GPSBaud);
}
void loop() {
while (gpsSerial.available() > 0)
if (gps.encode(gpsSerial.read()))
displayInfo();
// show error if it can't read anything in 5 seconds
if (millis() > 5000 && gps.charsProcessed() < 10) {
Serial.println("Sinal GPS não detectado");
while (true)
;
}
}
void displayInfo() {
if (gps.location.isValid()) {
float Lat = (float)gps.location.lat();
float Lng = (float)gps.location.lng();
EEPROM.put(address, Lat);
address += 4;
EEPROM.put(address, Lng);
address += 4;
Serial.println(Lat, 6);
Serial.println(Lng, 6);
Serial.println(EEPROM.get(address - 8, Lat), 6);
Serial.println(EEPROM.get(address - 4, Lng), 6);
Serial.println(address);
if (address >= 2040) {
address = 2032;
} else
Serial.println("Location invalid");
}
void dumpmem();
int buttonState = digitalRead(4);
float value = 0.0;
if (buttonState == HIGH) {
for (int index = 0; index < EEPROM.length(); index++) {
Serial.print(EEPROM.get(index, value), 6);
EEPROM[index] += 4;
}
return;
}
delay(6000);
}
This question thread is being automatically closed. If your question is not answered feel free to bump the post or re-ask. Take a look at !howto ask for tips on improving your question.
any idea what the issue could be? does the program crash?
It was working perfectly a few days ago
It compiles with no errors and I got my pins right
what's with the while (true);
infinite loops with no side effects are UB in C++
so the compiler would likely optimize out that entire if-statement if you compiled this with optimizations
Is that what is breaking the program?
unlikely, if it was working before
but it's something that doesn't belong there in general
are you sure you're not blocking the antenna?
- it doesn't work indoors
I know it doesn't
It was outside my window
I think I maybe fried it
But not a re because it still blinks the led
are you using a neo 6m?
Yeah, specifically the v2
This question thread is being automatically closed. If your question is not answered feel free to bump the post or re-ask. Take a look at !howto ask for tips on improving your question.