Getting Started with Apollo
Arduino IDE
The first thing you will need is the Arduino IDE. Download and install it from here. Once you have that installed, go ahead and open it up to make sure it is installed correctly. This should also have the side effect of Arduino creating a new folder inside your Documents folder, which we will need for the next step.
Libraries
To start running code on our board, you already have everything you need now. However, to work with certain components, like the display and sensors, you will want to install some libraries. To install a library, click the download link for it below, extract the zip file, rename the resulting folder so that the "-master" at the end is removed, and then place it in the "libraries" folder in <Your Documents Folder>/Arduino/libraries/. You will have to restart the Arduino IDE for it to find that library.
- Ascension's LiquidCrystalShift Driver (LCD module)
- Adafruit's TSL2561 Driver (light sensor)
- Adafruit's Unified Sensor Driver (part of the light sensor driver)
- Adafruit's BMP280 Driver (temperature and pressure sensor)
Once you have those three libraries installed, you will be able to use everything the Apollo has to offer. The SD Card driver is built into the Arduino IDE, along with a large number of other useful things, so you won't need to install a driver for anything else built into the board.
LCD How-to
To use the LCD, you simply need to make sure that the LCD library is installed as stated above, and then create an instance of the LCD. After creating the instance, you need to initialize it with the "begin" function. The code below demonstrates several aspects of using the LCD.
#include <LiquidCrystalShift.h>
//This line of code creates a global instance of the LCD module
LiquidCrystalShift lcd(7, 8, A3); //The next thing that needs to be done is to place "lcd.begin(16, 2)"
//in your setup function, as shown below
void setup() {
lcd.begin(16, 2); //This line sets up the display
}
//Inside your loop function, or anywhere else, you can display
//text and values on the screen by using print statements
void loop() {
lcd.setCursor(0, 0); //resets the cursor to the top left of the screen
lcd.print("Apollo!"); //prints the word "Apollo!" to the screen
lcd.setCursor(0, 1); //go to the second line
int volume = analogRead(A0); //read a potentiometer
lcd.print("Volume: ");
lcd.print(volume); //print the "volume" variable to the screen
lcd.print(" "); //prints a space after the pot value to clear
}
lcd.clear() is another useful function. It clears the display and reset the cursor to the top left, however you should avoid calling it continuously, since it makes the display look faded. If you add a "delay(30)" or some similar delay before you call lcd.clear(), you won't have any problems.
TSL2561 How-to (not included in new V2 boards)
Using the TSL2561 requires a very similar procedure to the LCD. Simply make sure that the light sensor's driver is installed, then create a global instance of the light sensor to use throughout your code.
#include <Adafruit_Sensor.h>
#include <Adafruit_TSL2561_U.h>
Adafruit_TSL2561_Unified tsl = Adafruit_TSL2561_Unified(TSL2561_ADDR_LOW, 12345);
void setup() {
//These two lines configure the light sensor to some good defaults
tsl.enableAutoRange(true);
tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_13MS);
}
void loop() {
//the next two lines talk to the light sensor
sensors_event_t event;
tsl.getEvent(&event);
//this line reads the amount of light the sensor saw when we asked
//on the two lines above
int brightness = event.light;
}
BMP280 How-to
#include <Adafruit_BMP280.h>
//this sets up a global instance of the pressure/temperature sensor
Adafruit_BMP280 bmp;
void setup() {
if(!bmp.begin(0x76))
{
// There was a problem detecting the pressure temperature sensor
// We will just blink the LED on pin 3 over and over to indicate
// that something went wrong.
// set pin 3 as an output
pinMode(3, OUTPUT);
// create an infinite while loop
while (true) {
//turn off the LED
digitalWrite(3, LOW);
delay(300); // wait 300ms
//turn on the LED
digitalWrite(3, HIGH);
delay(300); // wait another 300ms
}
}
}
void loop() {
//this will read the temperature in celsius
float temp = bmp.readTemperature();
//we could easily convert that into Fahrenheit if desired
float tempF = temp * 9.0 / 5.0 + 32;
}