Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Jackson NealMourad Amiei
Published

Charlotte Football Record Tracker

Use a couple of particles, an Alexa, and some other stuff to make an overcomplicated way of tracking your college's football team record!

IntermediateFull instructions provided3 hours223
Charlotte Football Record Tracker

Things used in this project

Hardware components

Argon
Particle Argon
×2
SunFounder IIC I2C TWI 1602 Serial LCD Module Display for Arduino R3 Mega 2560 16x2
×1
Echo Dot
Amazon Alexa Echo Dot
×1
3 mm LED: Red
3 mm LED: Red
×1
3 mm LED: Green
3 mm LED: Green
×1
Resistor 2.21k ohm
Resistor 2.21k ohm
×2
Resistor 220 ohm
Resistor 220 ohm
×1

Software apps and online services

Maker service
IFTTT Maker service
Amazon Alexa service
IFTTT Amazon Alexa service

Story

Read more

Code

Charlotte-Tracker-1

C#
This code will be flashed to the particle connected to the LCD.
// This #include statement was automatically added by the Particle IDE.
#include <LiquidCrystal_I2C_Spark.h>
#include <application.h>

//This line establishes the I2C lcd by calling its address, columns, and rows
LiquidCrystal_I2C lcd(0x27,16,2);

//New design. When Charlotte wins the game, user tells Alexa "Alexa, trigger Charlotte Won"
//Alexa then triggers publish to particle one
//Particle one then takes the information and publishes it to particle two
//Particle two displays the message, triggers the song to play, and publishes event to particle one
//Particle one lights up LEDs

//Function for when Charlotte Wins
void gameWon(const char *eventName, const char *data){
        
    //Setup the lcd for a new display
    lcd.init();
    lcd.clear();
    lcd.backlight();
    delay(1000);
    
    //Establish a blinking cursor
    lcd.blink();
    delay(1000);
    
    //Display first line
    lcd.home();
    lcd.printstr(" Charlotte ");
    lcd.setCursor(11,0);    //set cursor for result of the game
    lcd.printstr(data);
    lcd.printstr("!");
    
    //Set the cursor back at the start
    lcd.home();
    
    //Publish the time stamp for Charlotte winning
    data = String(data);
    Particle.publish("Charlotte_Won", data);
}

//Function for if by some crazy chance Charlotte Loses
void gameLost(const char *eventName, const char *data){
        
    //Setup the lcd for a new display
    lcd.init();
    lcd.clear();
    lcd.backlight();
    delay(1000);
    
    //Establish a blinking cursor
    lcd.blink();
    delay(1000);
    
    //Display first line
    lcd.home();
    lcd.printstr(" Charlotte ");
    lcd.setCursor(11,0);    //set cursor for result of the game
    lcd.printstr(data);

    
    //set the cursor back at the start
    lcd.home();
    
    //Publish the time stamp for Charlotte losing
    data = String(data);
    Particle.publish("Charlotte_Lost", data);
}

void setup() {
    //Setup the lcd for a new display
    lcd.init();
    lcd.clear();
    
    //Subscribe the the function published by the other particle
    Particle.subscribe("Lost", gameLost);
    Particle.subscribe("Won", gameWon);
}

void loop() {

}

Charlotte-Tracker-2

C#
This code will be flashed to the particle with the LED
//Establish shorthand for the pins used for the LEDs
int led1 = D0; 
int led2 = D7;
int led3 = D5;

//If Alexa Triggers "Charlotte Lost", the data is then sent to the other particle
void gameData1(const char *eventName, const char *data){
    Particle.publish("Lost", data);
}

//If Alexa Triggers "Charlotte Win", the data is then sent to the other particle
void gameData2(const char *eventName, const char *data){
    Particle.publish("Won", data);
}

//Once the other particle displays the winning message, it triggers the green LED for 3 seconds
void charlotteWon(const char *eventName, const char *data){
    //Initalize the pins
    pinMode(led1, OUTPUT);
    pinMode(led2, OUTPUT);

    //Turn on the green LED
    digitalWrite(led1, HIGH);
    digitalWrite(led2, HIGH);
    
    //Wait 5 seconds
    delay(5000);
    
    //Turn off the green LED
    digitalWrite(led1, LOW);
    digitalWrite(led2, LOW); 

}

//Once the other particle displays the losing message, it triggers the red LED for 3 seconds
void charlotteLost(const char *eventName, const char *data){
    //Initalize the pins
    pinMode(led1, OUTPUT);
    pinMode(led3, OUTPUT);

    //Turn on the red LED
    digitalWrite(led1, HIGH);
    digitalWrite(led3, HIGH);

    //Wait 5 seconds
    delay(5000);

    //Turn off the red LED
    digitalWrite(led1, LOW);
    digitalWrite(led3, LOW); 

}

void setup() {
    //Subscribes to the data coming from Alexa and IFTTT
    Particle.subscribe("Game_Lost", gameData1);
    Particle.subscribe("Game_Won", gameData2);
    
    //Subscribes to the output from the other particle
    Particle.subscribe("Charlotte_Won", charlotteWon);
    Particle.subscribe("Charlotte_Lost", charlotteLost);

}

void loop() {
}

Credits

Jackson Neal

Jackson Neal

1 project • 0 followers
Student MEGR 3171
Mourad Amiei

Mourad Amiei

0 projects • 0 followers

Comments