Last active
July 29, 2020 22:51
-
-
Save duanebester/bdb93ad2cff146c42277c5bfddaa67ed to your computer and use it in GitHub Desktop.
Arduino Tracker Setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setup() | |
{ | |
// Setup User Terminal | |
Serial.begin(115200); // UART to PC/Mac | |
while(!Serial); | |
Serial1.begin(9600); // UART to GPS | |
while(!Serial1); | |
// Initialize digital pin LED_BUILTIN as an output. | |
pinMode(LED_BUILTIN, OUTPUT); | |
pinMode(LEDR, OUTPUT); | |
pinMode(LEDB, OUTPUT); | |
pinMode(LEDG, OUTPUT); | |
digitalWrite(LEDR, HIGH); // LOW triggered LED.... | |
digitalWrite(LEDG, HIGH); | |
digitalWrite(LEDB, HIGH); | |
// Setup GPS | |
if (!myGPS.begin(Serial1)) { | |
Serial.println(F("GPS not detected!")); | |
while (1); | |
} | |
Serial.println("GPS Started!"); | |
// Setup SD Card | |
if (!SD.begin(chipSelect)) { | |
Serial.println("SD Card failed or not present!"); | |
while (1); | |
} | |
// Remove Existing DATALOG.CSV file | |
if(SD.exists("DATALOG.CSV")) { | |
SD.remove("DATALOG.CSV"); | |
dataFile = SD.open("DATALOG.CSV", FILE_WRITE); | |
dataFile.close(); | |
} | |
delay(500); // Make sure existing DATALOG.CSV file is gone | |
// Create new CSV file with appropriate headers | |
dataFile = SD.open("DATALOG.CSV", FILE_WRITE); | |
dataFile.println("Count,AccX,AccY,AccZ,GyrX,GyrY,GyrZ,Lat,Long,Speed"); | |
// Done with SD Card Init | |
Serial.println("SD Card Initialized!"); | |
// Setup Gesture Sensor | |
if (!APDS.begin()) { | |
Serial.println("Error initializing gesture sensor!"); | |
} | |
APDS.setGestureSensitivity(85); | |
Serial.println("Gesture sensor initialized!"); | |
// Setup IMU | |
if (!IMU.begin()) { | |
Serial.println("Failed to initialize IMU!"); | |
while(1); | |
} | |
Serial.println("IMU initialized!"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment