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!
Alex Merchen
Created May 30, 2019 © GPL3+

Password Holder with Avnet Brainium

Create a device that will show a password only if you do the right motion with the Avnet Brainium.

IntermediateFull instructions provided4 hours47
Password Holder with Avnet Brainium

Things used in this project

Hardware components

Adafruit Feather HUZZAH with ESP8266 WiFi
Adafruit Feather HUZZAH with ESP8266 WiFi
×1
Adafruit FeatherWing OLED
×1
5 mm LED: Red
5 mm LED: Red
×1
Resistor 330 ohm
Resistor 330 ohm
×1
SmartEdge Agile Brainium
Avnet SmartEdge Agile Brainium
×1

Software apps and online services

Arduino IDE
Arduino IDE
Avnet Brainium
Maker service
IFTTT Maker service
Adafruit IO

Story

Read more

Schematics

Wiring for Huzzah Feather

Code

Main Code

Arduino
#include "config.h"
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define BUTTON_A  0
#define BUTTON_B 16
#define BUTTON_C  2

Adafruit_SSD1306 display = Adafruit_SSD1306(128, 32, &Wire);

AdafruitIO_Feed *digital = io.feed("Shapes");

int lastButton = 1;

int order = 1;
  
void setup() {
  
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);
  pinMode(14, OUTPUT);
  
  Serial.begin(115200);

  display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // Address 0x3C for 128x32

  display.display();
  delay(1000);

  // Clear the buffer.
  display.clearDisplay();
  display.display();

  pinMode(BUTTON_A, INPUT_PULLUP);
  pinMode(BUTTON_B, INPUT_PULLUP);
  pinMode(BUTTON_C, INPUT_PULLUP);
  
  while(! Serial);

  Serial.print("Connecting to Adafruit IO");
  io.connect();

  digital->onMessage(handleMessage);

  while(io.status() < AIO_CONNECTED) {
    Serial.print(".");
    delay(500);
  }

  Serial.println();
  Serial.println(io.statusText());
  digital->get();

}

void loop() {

  io.run();
  if(!digitalRead(BUTTON_A) && lastButton == 1){
    digital->save(2);
    lastButton = 2;
  }
  else if(!digitalRead(BUTTON_B) && lastButton == 2){
    digital->save(3);
    lastButton = 1;
  }
    
}

void handleMessage(AdafruitIO_Data *data) {

  Serial.print("received <- ");
  int x = data->toInt();
  
  if(x == 1 && order == 1){
    digitalWrite(12, HIGH);
    order = 2;
  }
  else if(x == 2 && order == 2){
    digitalWrite(13, HIGH);
    order = 3;
  }
  else if(x == 3 && order == 3){
    digitalWrite(14, HIGH);
    order = 4;
    display.setTextSize(1);
    display.setTextColor(WHITE);
    display.setCursor(0,0);
    display.print("The WiFi Network is:\n  X#X#X#X#X#X-WiFi");
    display.println("\nPassword: \n  X#X#X#X#X#");
    display.setCursor(0,0);
    display.display();
  }
  else{
    digitalWrite(12, LOW);
    digitalWrite(13, LOW);
    digitalWrite(14, LOW);
    order = 1;
    display.clearDisplay();
    display.display();
  }
  Serial.println(x);
  
  
}

config.h

Arduino
/************************ Adafruit IO Config *******************************/

// visit io.adafruit.com if you need to create an account,
// or if you need your Adafruit IO key.
#define IO_USERNAME  "your_username"
#define IO_KEY       "your_io_key"

/******************************* WIFI **************************************/

// the AdafruitIO_WiFi client will work with the following boards:
//   - HUZZAH ESP8266 Breakout -> https://www.adafruit.com/products/2471
//   - Feather HUZZAH ESP8266 -> https://www.adafruit.com/products/2821
//   - Feather HUZZAH ESP32 -> https://www.adafruit.com/product/3405
//   - Feather M0 WiFi -> https://www.adafruit.com/products/3010
//   - Feather WICED -> https://www.adafruit.com/products/3056
//   - Adafruit PyPortal -> https://www.adafruit.com/product/4116
//   - Adafruit Metro M4 Express AirLift Lite -> https://www.adafruit.com/product/4000
//   - Adafruit AirLift Breakout -> https://www.adafruit.com/product/4201

#define WIFI_SSID   "your_wifi"
#define WIFI_PASS   "your_password"

// uncomment the following line if you are using airlift
// #define USE_AIRLIFT

// uncomment the following line if you are using winc1500
// #define USE_WINC1500

// comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h"

#if defined(USE_AIRLIFT) || defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE)
  // Configure the pins used for the ESP32 connection
  #if !defined(SPIWIFI_SS) // if the wifi definition isnt in the board variant
    // Don't change the names of these #define's! they match the variant ones
    #define SPIWIFI SPI
    #define SPIWIFI_SS 10  // Chip select pin
    #define SPIWIFI_ACK 9  // a.k.a BUSY or READY pin
    #define ESP32_RESETN 6 // Reset pin
    #define ESP32_GPIO0 -1 // Not connected
  #endif
  AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS, SPIWIFI_SS, SPIWIFI_ACK, ESP32_RESETN, ESP32_GPIO0, &SPIWIFI);
#else
  AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS);
#endif
/******************************* FONA **************************************/

// the AdafruitIO_FONA client will work with the following boards:
//   - Feather 32u4 FONA -> https://www.adafruit.com/product/3027

// uncomment the following two lines for 32u4 FONA,
// and comment out the AdafruitIO_WiFi client in the WIFI section
// #include "AdafruitIO_FONA.h"
// AdafruitIO_FONA io(IO_USERNAME, IO_KEY);

/**************************** ETHERNET ************************************/

// the AdafruitIO_Ethernet client will work with the following boards:
//   - Ethernet FeatherWing -> https://www.adafruit.com/products/3201

// uncomment the following two lines for ethernet,
// and comment out the AdafruitIO_WiFi client in the WIFI section
// #include "AdafruitIO_Ethernet.h"
// AdafruitIO_Ethernet io(IO_USERNAME, IO_KEY);

Credits

Alex Merchen

Alex Merchen

24 projects • 39 followers
I'm an EE with a Masters in ECE. I like building things.

Comments