Things used in this project

Hardware components:
Abx00004 iso both
Arduino MKR1000 & Genuino MKR1000
×1
ATX Power Supply
×1
Adafruit coin acceptor
×1
Adafruit Proto Screw Shield
×1
Adafruit GRAPHIC ST7565 POSITIVE LCD (128X64) WITH RGB BACKLIGHT + EXTRAS
×1
Adafruit LOCK-STYLE SOLENOID - 12VDC
×1
SeeedStudio BADGEr_v4
×1
08377 02 l
Resistor 330 ohm
×3
Mfr 25fbf52 22r1 sml
Resistor 22.1 ohm
×1
Panasonic eca1hm2r2
Capacitor 10 µF
×1
Kemet c320c104k5r5ta image
Capacitor 100 nF
×2
09939 01
Rotary potentiometer (generic)
×1
Texas Instruments lm386
×1
Adafruit industries ada1536 image
Buzzer
×1
11026 02
Jumper wires (generic)
A lot of wire. and a lot of colors
×1
Software apps and online services:
Ide web
Arduino IDE
Vs2015logo
Microsoft Visual Studio 2015
W9gt7hzo
Microsoft Azure
QR generator.
Images
CircuitMaker by Altium Circuit Maker
Fritzing
EagleCAD
SeeedStudio WyoLum for Badger
paint
Hand tools and fabrication machines:
Lasercutter
Laser cutter (generic)
3drag
3D Printer (generic)
09507 01
Soldering iron (generic)
Hy gluegun
Hot glue gun (generic)
Dremel Rotary tool

Custom parts and enclosures

Corner for 3D print
Print 4, made for 3mm acrylic.
I created this one for 3D printing, for both screens i use
Door lock
3D print and use for 3mm Acrylic
Coin Separator for mexican pesos
Coin sorter customized for mexican pesos.
Vynil sticker
Stickr for Schoredinger bank
CORTE.dxf

Schematics

Image for the schematic
This is the wiring for this project ---> Use MKR1000 instead of YUN
Iotforcoins
IoT for Coins
Schematic for this project.
IoT for Coins.fzz

Code

IoT for CoinsArduino
The hybrid program for Azure via POST and arduino
// Erik Moran 
// IoT for Coins
//
// PINout
// pin 3 - Coin 
//
// pin 6 - GLCD
// pin 7 - GLCD
// pin 8 - GLCD
// pin 9 - GLCD
// pin 10 - GLCD
//
// pin 2 - r
// pin 1 - g
// pin 0 - b
//
// pin 5 - Locker
//
// pin 4 - Chip slct
// pin 10 - mosi /SD
// pin 8 - miso /SD
// pin 9 -sck /SD
//
// pin A1- Random seed.
//
// pin A0 - Buzzer-Sound
//

#include <SD.h>
#include <SPI.h>
#include <AudioZero.h>
#include <WiFi101.h>
#include "ST7565.h"

// Internet password
char ssid[] = "Network Name";     //  your network SSID (name) 
char pass[] = "Password";    // your network password
int keyIndex = 0;                 // your network key Index number (needed only for WEP)

int status = WL_IDLE_STATUS;
WiFiServer server(80);
String IP;

// Coin Acceptor
const int CoinPin = 3;     // the number of the pushbutton pin
int cash = 0;
int t = 0;

//Graphic Liquid Cristal display - GLCD
ST7565 glcd(10, 9, 8, 7, 6);
char Val[5]; 

unsigned long duration;

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status
int buttonState1 = 0;   

int vx;//variable x
int vy;//resultado
int vc;//constante
int vl;//A
int re;//respuesta del usuario
int st = 0;
//2 1 0 pines r g b
int pr = 2;
int pg = 1;
int pb = 0;

int locker = 5;

void setup() {
  Serial.begin(9600);
  
  pinMode(CoinPin, INPUT);

// GLCD background color
  pinMode(pr, OUTPUT);
  pinMode(pg, OUTPUT);
  pinMode(pb, OUTPUT);

  digitalWrite(pr, LOW);
  digitalWrite(pg, LOW);
  digitalWrite(pb, LOW);

  pinMode(locker, OUTPUT); //locker

  glcd.begin(0x18);
  //pon algo de IOT
  // delay(2000);
  glcd.clear(); 

  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    while (true);       // don't continue
  }

  // attempt to connect to Wifi network:
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to Network named: ");
    Serial.println(ssid);                   // print the network name (SSID);

    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
    status = WiFi.begin(ssid, pass);
    // wait 10 seconds for connection:
    delay(10000);
  }
  server.begin();                           // start the web server on port 80
  printWifiStatus();                        // you're connected now, so print out the status

  randomSeed(analogRead(1));
  genera_ec();//inicializa pw
}

void loop() {

// Read the pulse for coin
  duration = pulseIn(CoinPin, HIGH);
  if(duration > 0){
    cash++;
    }else {
        if (t != cash) {
          Serial.println(cash);
            t = cash;
        }
    }

  sprintf(Val, "%d", cash);

  char IPc[24];
  IP.toCharArray(IPc, 24);

  glcd.drawstring(0, 0, IPc);
  glcd.drawstring(0, 1, "IOT for Coins");
  glcd.drawstring(0, 2, "You have:");
  glcd.drawstring(0, 3, Val);
  glcd.display();
  //delay(2000);
  glcd.clear();
 
 // Serial.println(duration);

  WiFiClient client = server.available();   // listen for incoming clients

  if (client) {                             // if you get a client,
    Serial.println("new client");           // print a message out the serial port
    String currentLine = "";                // make a String to hold incoming data from the client
    while (client.connected()) {            // loop while the client's connected
      if (client.available()) {             // if there's bytes to read from the client,
        char c = client.read();             // read a byte, then
        Serial.write(c);                    // print it out the serial monitor
        if (c == '\n') {                    // if the byte is a newline character

          // if the current line is blank, you got two newline characters in a row.
          // that's the end of the client HTTP request, so send a response:
          if (currentLine.length() == 0) {
            // HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
            // and a content-type so the client knows what's coming, then a blank line:
            client.println("HTTP/1.1 200 OK");
            client.println("Content-type:text/html");
            client.println();
            
            client.print("<link rel=\"shortcut icon\" href=\"http://www.example.com/my_empty_resource\" />");
            client.print("<script src=\"//code.jquery.com/jquery-1.12.0.min.js\"></script>");
            client.print("<style>body {text-align: center; font-size: 18px; color: #333; text-shadow: 0px 0px 3px #ccc; font-family: Verdana;}</style>");

            client.print("Current cash:<br>");
            client.print(cash);

            client.print("<br/><br/>");
            if(vx != 1) client.print(vl);
            client.print("x");//vx
            if(vc < 0) {
              client.print("");
            } else {
              client.print(" + ");
            }
            client.print(vc);
            client.print(" = ");
            client.print(vy);
            client.print("<br/>x = <input type='text' id='respuesta' value=''/>");
            client.print("<input type='button' id='enviar' value='enviar'/>");

            /*
            client.print("<script>$(\"#respuesta\").keyup(function (e) {if (e.keyCode == 13) {window.location='http://'+self.location.hostname+'/'+String.fromCharCode(parseInt($(\"#respuesta\").val())+65);}});</script>");
            client.print("<script>$(\"#enviar\").click(function (e) {window.location='http://'self.location.hostname+'/'+String.fromCharCode(parseInt($(\"#respuesta\").val())+65);});</script>");
            */
            client.print("<script>$(\"#respuesta\").keyup(function (e) {if (e.keyCode == 13) {window.location='http://'+self.location.hostname+'/'+(parseInt($(\"#respuesta\").val())+65);}});</script>");
            client.print("<script>$(\"#enviar\").click(function (e) {window.location='http://'self.location.hostname+'/'+(parseInt($(\"#respuesta\").val())+65);});</script>");
            client.print("<script>$(\"#respuesta\").focus();</script>");

            // The HTTP response ends with another blank line:
            client.println();
            digitalWrite(pg, LOW);
            digitalWrite(locker, LOW);//abre locker
            // break out of the while loop:
            break;//!!!
          }
          else {      // if you got a newline, then clear currentLine:
            currentLine = "";
          }
        }
        else if (c != '\r') {    // if you got anything else but a carriage return character,
          currentLine += c;      // add it to the end of the currentLine
        }

        // Check to see if the client request was correct or wrong.
        if (currentLine.endsWith("GET /HH")) {
          digitalWrite(locker, HIGH);            
        }
        if (currentLine.endsWith("GET /LL")) {
          digitalWrite(locker, LOW);            
        }
        if (currentLine.endsWith("GET /"+String(vx+65))) {
        //if (currentLine.endsWith("GET /"+int(vx))) {
            st = 1;
            genera_ec();
            digitalWrite(pg, HIGH);
            digitalWrite(locker, HIGH);//abre locker
          }
          if (currentLine.endsWith("GET /NN")) {
            st = 1;
            genera_ec();
          }
          if (currentLine.endsWith("GET /RR")) {
            client.print("<br/>*<br/>");
            client.print(vx);
            client.print("<br/>*<br/>");
            client.print(String(vx+65));
            client.println();
            
            //digitalWrite(pg, HIGH);
            //digitalWrite(locker, HIGH);//abre locker
          }
      }
    }
    // close the connection:
    client.stop();
    Serial.println("client disonnected");
  }
 
}


String DisplayAddress(IPAddress address)
{
 return String(address[0]) + "." + 
        String(address[1]) + "." + 
        String(address[2]) + "." + 
        String(address[3]);
}

void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);
  IP = DisplayAddress(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
  // print where to go in a browser:
  Serial.print("To see this page in action, open a browser to http://");
  Serial.println(ip);
}



void genera_ec() {
  vx = random(0, 9);
  vc = random(-20, 20);
  vl = random(1,5);
  vy = (vl*vx)+vc;
  re = 0;
}
GLCD library
This is the library for the GLCD from Adafruit.

Credits

Photo
Erik Moran

Maker from the big city.

Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

Arduino Like Function on Kinetis K82 Freedom Stupid Board
Intermediate
  • 89
  • 4

Protip

1000 of K82 Freedom Boards are collecting dust because of the hobbyist unfriendly IDE, pump up the duds with easy Arduino-like functions.

DIY Patient Thermometer for Healthcare Training
Intermediate
  • 91
  • 3

Work in progress

DIY thermometer, IR remote controlled. 9 different temperatures. For use in healthcare simulation training. Cost-effective solution.

Horus: The Weather Station
Intermediate
  • 250
  • 5

Full instructions

A Raspberry Pi-based weather station that measures temperature, humidity and pressure using the Astro Pi Sense HAT and uploads the data.

Reducing Arduino Power Consumption
Intermediate
  • 181
  • 5

Full instructions

One the most important feature of portable electronics should be long battery life. We can reduce the current drawn by several ways.

Raspberry Pi Motion Tracking Gun Turret
Intermediate
  • 7,969
  • 19

Full instructions

A motion tracking airsoft or Nerf gun turret with autonomous and manual operation modes, controlled by a Raspberry Pi.

Arduinomated Car Parking with Voice Assistance in Smartphone
Intermediate
  • 721
  • 12

Full instructions

Make an assistant which tells you about how much to drive backwards without any collision through your smartphone by Arduino and 1Sheeld.

Sign up / LoginProjectsPlatformsTopicsContestsLiveAppsBetaFree StoreBlog