Showing posts with label Test. Show all posts
Showing posts with label Test. Show all posts

2012/11/14

GlobalSat EM-411 GPS Module Test Sketch Using Arduino 0022

Once buying an GPS module, the first idea is to check whether the module works as expect. To check the module using Arduino, first connecting the module and Arduino Uno/Duemilanove, then using the following sketch running on Arduino IDE 0022 (should also run on 0023 but not tested). The sketch should work for other GPS module, because GPS module usually need only VCC, GND to run and additional TX and RX to transmit/recive data.
As soon as checked the connections and powering the Arduino Uno/Duemilanove , one can monitor the NMEA sentenc output using Arduino serial monitor or any terminal emulator such as Putty. For me, I use SSCOM to test GPS and bluetooth modules on Windows XP.

Pin Used And Connection

Arduino - GPS Module
5V - Pin2(VIN)
GND - Pin1(GND) and Pin5(GND)
D2(SoftwareSerial RX) - Pin3(TX)
D3(SoftwareSerial TX) - Pin4(RX)

Output


Sketch 

// Test Code for GlobalSat EM-411 GPS Modules 
// Arduino 0022 Has Built-in SoftwareSerial.h Library
// Download the Library is not Needed
// The sketch works on Arduino IDE 0022

#include <SoftwareSerial.h>
SoftwareSerial GPS = SoftwareSerial(2, 3);

void setup()  
{
  Serial.begin(9600);
  Serial.println("GlobatSat EM-411 GPS Module NMEA Sentence Test!");

  // EM-411 factory default baud rate is 4800, the module used has been changed the baud rate
  GPS.begin(9600);
}

void loop()  // whatever read from GPS, sent to Arduino serial monitor or terminal emulator
{
  Serial.print(GPS.read(), BYTE);
}

2012/05/22

Sketch for Testing Freeduino/Arduino LCD Keypad Shield

Pins Used

D8, D9, D4, D5, D6, D7, A0

Serial Monitor Output
Sketch


/*
  ASCII table

 Prints out byte values in all possible formats:  
 * as raw binary values
 * as ASCII-encoded decimal, hex, octal, and binary values

 For more on ASCII, see http://www.asciitable.com and http://en.wikipedia.org/wiki/ASCII

 The circuit:  No external hardware needed.

 created 2006
 by Nicholas Zambetti 
 modified 18 Jan 2009
 by Tom Igoe

 modified by Befun Hung on Sunday, 20 May 2012
 file name: LCDKeypadShieldTestKeyNone.pde
 for use in testing 16x2 LCD module
 added codes from acw@home (HKEPC Hardware) to test Keypad on Monday, 21 May 2012
 added codes for debouncing and key touching on Tuesday, 22 May 2012

 This example code is in the public domain.
 The sketch works on Arduino IDE 0022

 <http://www.zambetti.com> 

 */
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

// analog PIN A0
#define KEY_PIN 0
#define KEY_NONE 1020
int key;
int last_key = -1; //save the last key pressed

void setup() 
{ 
  Serial.begin(9600); 
  lcd.begin(16, 2);
  last_key = KEY_NONE;
  lcd.clear();

  // prints title with ending line break 
  // Serial.println("ASCII Table ~ Character Map"); 
} 

// first visible ASCIIcharacter '!' is number 33:
int thisByte = 33; 
// you can also write ASCII characters in single quotes.
// for example. '!' is the same as 33, so you could also use this:
//int thisByte = '!';  

void loop() 
{ 
  // prints value unaltered, i.e. the raw binary version of the 
  // byte. The serial monitor interprets all bytes as 
  // ASCII, so 33, the first number,  will show up as '!' 
  
  // lcd.clear();
  for (int i=0;i<16;i++)
  {
    Serial.print(thisByte, BYTE); 
    lcd.setCursor(i, 0);
    lcd.print(char(thisByte));
    lcd.setCursor(i, 1);
    lcd.print(char(thisByte));
    delay(50);
  }
  Serial.println();
  // Serial.print(", dec: "); 
  // prints value as string as an ASCII-encoded decimal (base 10).
  // Decimal is the  default format for Serial.print() and Serial.println(),
  // so no modifier is needed:
  // Serial.print(thisByte);      
  // But you can declare the modifier for decimal if you want to.
  //this also works if you uncomment it:

  // Serial.print(thisByte, DEC);  


  // Serial.print(", hex: "); 
  // prints value as string in hexadecimal (base 16):
  // Serial.print(thisByte, HEX);     

  // Serial.print(", oct: "); 
  // prints value as string in octal (base 8);
  // Serial.print(thisByte, OCT);     

  // Serial.print(", bin: "); 
  // prints value as string in binary (base 2) 
  // also prints ending line break:
  // Serial.println(thisByte, BIN);   

  // if printed last visible character '~' or 126, stop: 
  if(thisByte == 126) {     // you could also use if (thisByte == '~') {
    lcd.clear();
    // This loop loops forever and does nothing
    while(true) {
      key = analogRead(KEY_PIN);
      delay(200); // for debouncing
      if (key <= KEY_NONE && key != last_key) {
        lcd.setCursor(0,1);
        lcd.print(key);
        lcd.print("    ");
        Serial.println(key);
        last_key = key;
      }
      continue; 
    } 
  } 
  // go on to the next character
  thisByte++;  
  delay(100);
}