NerdFatherRJ
Published © GPL3+

Smart Coin Dispenser

Retrive coins the old way pushing buttons or the future way through Alexa or any voice assistant.

IntermediateShowcase (no instructions)2,416
Smart Coin Dispenser

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
Keypad
×1
IR receiver 3pin
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Cardboard
×1
Duble taped 3M
×1

Software apps and online services

Arduino IDE
Arduino IDE
Alexa Voice Service
Amazon Alexa Alexa Voice Service
Universal Remote app and device

Story

Read more

Schematics

Scheme

Its showed with Arduino Uno but I did use a Nano board and the same pins

Code

Smart Coin Feeder

Arduino
/*
 * Device for retrieve coins in a given amount.
 * Works Manually trough keypad presses (only 1 to 9)
 * Works remotely with a remote control.
 * Works with voice commands trough Alexa or other vice assistants. Need also an Universal Remota Controlfor home automation.
 * Make the UR learn the remote control and configura apropriate scenes and routines in Alexa.
 * 
 * Feel free to develop and improve! and please let me know.
 * 
 * Arduino Project Hub
 * NerdFatherRj - Rio de Janeiro - BRA - Dec.2020.
 * 
 */


#include <IRremote.h>
#include <ir_Lego_PF_BitStreamEncoder.h>

#include <Servo.h>
#include <Keypad.h> 
Servo Srv;

int RECV_PIN = 12;  //digital port for IR Led
float armazenavalor1;  
float armazenavalor2;
IRrecv irrecv(RECV_PIN);  
decode_results results;  

const byte LINHAS = 4; // keypad lines
const byte COLUNAS = 4; // keypad columns

const char TECLAS_MATRIZ[LINHAS][COLUNAS] = { // keyboard mapping
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};

const byte PINOS_LINHAS[LINHAS] = {9, 8, 7, 6}; // keypad lines
const byte PINOS_COLUNAS[COLUNAS] = {5, 4, 3, 2}; // keypad columns
Keypad teclado_personalizado = Keypad(makeKeymap(TECLAS_MATRIZ), PINOS_LINHAS, PINOS_COLUNAS, LINHAS, COLUNAS); // keypad on

int Fora = 50; //Must calibrate to suit your needs.
int Dentro = 150; //Must calibrate to suit your needs.

void setup() {
Serial.begin(9600); 
pinMode(12,INPUT);// ir module
irrecv.enableIRIn(); // ir initialize
Srv.attach(11); 
delay(250); 
Srv.write(Fora); //lever out waiting for pushing the coins.
}

void loop() {

char leitura_teclas = teclado_personalizado.getKey(); 
  switch (leitura_teclas){

  case '1': //keypad 1 pressed and so on
  pushPull1();
break;

  case '2':
 pushPull2();
   break;

  case '3':
 pushPull3();
 break;

  case '4':
  pushPull4();
break;

  case '5':
  pushPull5();
 break;

  case '6':
 pushPull6();
 
 break;
 
  case '7':
  pushPull7;
 
break;
  case '8':
 pushPull8();
 break;
 
  case '9':
 pushPull9();
break;
    
} //end switch

/* Routines for IR control */

if (irrecv.decode(&results))  {  
    Serial.print("Valor lido : ");  
    Serial.println(results.value, HEX); 
   armazenavalor1 = (results.value); 
  irrecv.resume();  
  armazenavalor2 = (results.value);  
delay(500);


 if (armazenavalor1 == 0xFF30CF ){ //button "1" pressed  
 pushPull1();
}
irrecv.resume(); 

if (armazenavalor1 == 0xFF18E7  ){ //button "2" pressed  
pushPull2();
}
irrecv.resume(); //Le o prximo valor 
 
if (armazenavalor1 == 0xFF7A85  ){ //button "3" pressed  
pushPull3();
}

irrecv.resume(); //Le o prximo valor 

if (armazenavalor1 == 0xFF10EF  ){ //button "4" pressed  
pushPull4();
}

irrecv.resume(); //Le o prximo valor 
  
if (armazenavalor1 == 0xFF38C7  ){ //button "5" pressed  
pushPull5();
}

irrecv.resume(); //Le o prximo valor 
 
if (armazenavalor1 == 0xFF5AA5  ){ //button "6" pressed  
pushPull6();
}
irrecv.resume(); //Le o prximo valor 
  
if (armazenavalor1 == 0xFF42BD  ){ //button "7" pressed  
pushPull7();
}
irrecv.resume(); //Le o prximo valor 
 
if (armazenavalor1 == 0xFF4AB5 ){ //button "8" pressed  
pushPull8();
}

irrecv.resume(); //Le o prximo valor 
  
if (armazenavalor1 == 0xFF52AD ){ //button "9" pressed  
pushPull9();
}

irrecv.resume(); //Le o prximo valor 

 }//end if decodresults
} //end loop


  void pushPull(){
Srv.write(Dentro);
 delay(300);
  Srv.write(Fora);
  delay(300);
  }

  void pushPull1() {
pushPull();
}

 void pushPull2() {
pushPull();
pushPull();
}

 void pushPull3() {
pushPull();
pushPull();
pushPull();
}

 void pushPull4() {
pushPull();
pushPull();
pushPull();
pushPull();
}

 void pushPull5() {
pushPull();
pushPull();
pushPull();
pushPull();
pushPull();
}

 void pushPull6() {
pushPull();
pushPull();
pushPull();
pushPull();
pushPull();
pushPull();
}

 void pushPull7() {
pushPull();
pushPull();
pushPull();
pushPull();
pushPull();
pushPull();
pushPull();
}

 void pushPull8() {
pushPull();
pushPull();
pushPull();
pushPull();
pushPull();
pushPull();
pushPull();
pushPull();
}

 void pushPull9() {
pushPull();
pushPull();
pushPull();
pushPull();
pushPull();
pushPull();
pushPull();
pushPull();
pushPull();
 }

Credits

NerdFatherRJ

NerdFatherRJ

5 projects • 27 followers

Comments