#include <Wire.h> /************************** Configuration ***********************************/ // edit the config.h tab and enter your Adafruit IO credentials // and any additional configuration needed for WiFi, cellular, // or ethernet clients. #include "config.h" // Adafruit Feeds AdafruitIO_Feed *holdings = io.feed("holdings"); AdafruitIO_Feed *bet = io.feed("bet"); int button = 16; // push button is connected int bank = 0; int betInc = 0; int count = 0; int currentState = 0; int lastState = 0; bool bPress = false; void setup() { Serial.begin(9600); /* begin serial for debug */ // connect to io.adafruit.com io.connect(); // wait for a connection while(io.status() < AIO_CONNECTED) { Serial.print("."); delay(500); } // we are connected Serial.println(); Serial.println(io.statusText()); Serial.println("Welcome to DigiPoker!"); Serial.println("Please input your initial holdings and your bet increment value (separated by a space): "); while (Serial.available() == 0) { } bank = Serial.parseFloat(); //Read the data the user has input betInc = Serial.parseFloat(); //Read the data the user has input Serial.print("Your holdings: $" ); //Prompt User for Input Serial.println(bank); //Prompt User for Input Serial.print("Your bet increment: $" ); //Prompt User for Input Serial.println(betInc); //Prompt User for Input pinMode(button, INPUT); } void loop() { // io.run(); is required for all sketches. // it should always be present at the top of your loop // function. it keeps the client connected to // io.adafruit.com, and processes any incoming data. io.run(); //Uncomment this to send some information to Arduino /* Wire.beginTransmission(8); // begin with device address 8 Wire.write("Hello Arduino"); // sends hello string Wire.endTransmission(); // stop transmitting */ checkPress(); if(bPress){ bPress = false; Serial.println(count); Serial.println(bank); //Send the received data to cloud holdings->save(bank); bet->save(count); delay(2000); Serial.println(); delay(1000); } } void checkPress() { currentState = digitalRead(button); if (currentState != lastState) { if (currentState == LOW) { bPress = true; count = count + betInc; bank = bank - betInc; } else { // Serial.println("off"); } delay(50); } lastState = currentState; }