benstr πŸš€
Published © CC BY-SA

Mobile Vote Box

Ever wonder what others are thinking about a particular question? This machine will ask it for you and stores results in the cloud.

BeginnerFull instructions provided1 hour4,269
Mobile Vote Box

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Adafruit FONA mini GSM breakout
×1
Solderless Breadboard Full Size
Solderless Breadboard Full Size
×1
Adafruit Colorful Round Tactile Button Switch
×2
LED (generic)
LED (generic)
×3

Software apps and online services

Hologram Data Router
Hologram Data Router
Maker service
IFTTT Maker service

Story

Read more

Schematics

Breadboard Layout

Code

Mobile Vote Box Arduino code - v1

C/C++
You'll need to manually add the HologramSIMCOM library to your Arduino IDE - https://github.com/hologram-io/hologram-SIMCOM
#include <HologramSIMCOM.h>

#define RX_PIN 2 //SIMCom RX - MCU TX
#define TX_PIN 3 //SIMCom TX - MCU RX
#define RESET_PIN 4 //SIMCom reset
#define HOLO_KEY "########" //replace w/your SIM key
#define CONNECT_LED 12
#define VOTE1_BTN_PIN 6
#define VOTE1_LED_PIN 7
#define VOTE2_BTN_PIN 9
#define VOTE2_LED_PIN 10

HologramSIMCOM Hologram(TX_PIN, RX_PIN, RESET_PIN, HOLO_KEY); // Instantiate Hologram

String VOTE1_VALUE = "chicago";
String VOTE2_VALUE = "newYork";
String HOLOGRAM_TOPIC = "vote";

void setup() {
  Serial.begin(19200);
  while(!Serial);

  // Start modem and connect to Hologram's global network
  Hologram.debug();

  //set modes for used pins
  pinMode(CONNECT_LED, OUTPUT);
  pinMode(VOTE1_BTN_PIN, INPUT);
  pinMode(VOTE1_LED_PIN, OUTPUT);
  pinMode(VOTE2_BTN_PIN, INPUT);
  pinMode(VOTE2_LED_PIN, OUTPUT);
  
  bool cellConnected = Hologram.begin(19200, 8888); // set baud to 19200 and start server on port 8888
  if(cellConnected) {
    digitalWrite(CONNECT_LED, HIGH);
  }
}

void loop() {
  Hologram.debug();

  if(digitalRead(VOTE1_BTN_PIN) == HIGH) {
    sendVote(VOTE1_VALUE,VOTE1_LED_PIN);
  }

  if(digitalRead(VOTE2_BTN_PIN) == HIGH) {
   sendVote(VOTE2_VALUE,VOTE2_LED_PIN);
  }
}

void sendVote(String VOTE_VALUE, const int VOTE_LED) {
  digitalWrite(VOTE_LED, HIGH); 
  // send to the Hologram Data Router
  if(Hologram.send(VOTE_VALUE, HOLOGRAM_TOPIC)) {
    // blink LED if vote was successful
    // this is crappy code, consider refactoring
    digitalWrite(VOTE_LED, LOW);
    delay(100);
    digitalWrite(VOTE_LED, HIGH);
    delay(100);
    digitalWrite(VOTE_LED, LOW);
    delay(100);
    digitalWrite(VOTE_LED, HIGH);
    delay(100);
    digitalWrite(VOTE_LED, LOW);
  } else {
    digitalWrite(VOTE_LED, LOW);
  }
}

Credits

benstr πŸš€

benstr πŸš€

4 projects β€’ 108 followers
Connecting the world with Soracom.io and AWS.

Comments