Shop OBEX P1 Docs P2 Docs Learn Events
parallax gps module in smart mode with the arduino microcontroller — Parallax Forums

parallax gps module in smart mode with the arduino microcontroller

JavibooJaviboo Posts: 2
edited 2010-07-23 18:08 in General Discussion
Hi, I am trying to use a parallax gps module in smart mode with an arduino microcontroller.
The code I am attempting to use is attached below. My problem is that it isn't returning anything useful.
The computer serial moniter just shows:
!GPS
!GPS
!GPS
!GPS
!GPS
!GPS
Over and over again. Could anyone point out what we are doing wrong? The code below was converted from one that output to an LCD display to one that outputs to the Serial monitor. We have also implemented a diode as suggested here: http://forums.parallax.com/forums/default.aspx?f=15&m=436519

boolean requested = false;
int byteRead = 0;

byte getValid = B00000001;
byte getVersion = B00000000;
byte getTime = B00000011;
byte getDate = B00000100;
//byte getDate = 0x04;
void setup() {
Serial.begin(4800);
}

void loop() {
while (!requested) {
Serial.println("!GPS");
Serial.write(getVersion);
requested = !requested;
}
while (requested) {

while (Serial.available()) {
byteRead = Serial.read();
Serial.print("Received: ");
Serial.println(byteRead, DEC);
delay(1000);
}
requested = !requested;
}
}

Comments

  • FranklinFranklin Posts: 4,747
    edited 2010-07-23 04:00
    while (!requested) {
    Serial.println("!GPS");
    Serial.write(getVersion);
    requested = !requested;
    }
    
    

    If this loop starts where does it ever break out?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • JavibooJaviboo Posts: 2
    edited 2010-07-23 18:08
    I didn't write the code so I might be incorrect but I believe the while loop breaks after cycling through its contents once.

    The last line reads "requested = !requested;" which should break the loop because it should turn the boolean requested from true to false.
    Franklin said...
    while (!requested) {
    Serial.println("!GPS");
    Serial.write(getVersion);
    requested = !requested;
    }
    
    


    If this loop starts where does it ever break out?
Sign In or Register to comment.