Things used in this project

Hardware components:
Photon new
Particle Photon
×1
Ardgen mega
Arduino Mega 2560 & Genuino Mega 2560
×1
Pi 3 02
Raspberry Pi 3 Model B
×1
Adafruit industries ada1314 image
Speaker: 3W, 4 ohms
×1
Voice HAT for Raspberry Pi
×1
Mic Array
×1
Arcade Button and Micro Switch
×1
Servo (Continuous Rotation)
×1
11026 02
Jumper wires (generic)
×1
Te connectivity 4 103741 0 image 75px
Male Header 40 Position 1 Row (0.1")
×1
Pppc081lfbn rc sml
Female Header 8 Position 1 Row (0.1")
×1
SparkFun APDS-9960
×1
181 02
Adafruit Standard LCD - 16x2 White on Blue
×1
Omron b3f 1000 image 75px
SparkFun Pushbutton switch 12mm
×2
Software apps and online services:
Ide web
Arduino IDE
IFTTT Assistant Service
Particle Photon Build IDE
Aiy projects 4 bgsoumwo5r
Google AIY Projects
Hand tools and fabrication machines:
09507 01
Soldering iron (generic)
3drag
3D Printer (generic)

Custom parts and enclosures

This is from Thingiverse for the Automated Cat Feeder: http://www.thingiverse.com/thing:27854 You will need a 1.5" T-joint PVC pipe as well.
Button Holder
This holds the actual button in place.
Button
This slides into the button holder piece. It is what the user presses. Make sure it can slide freely.
Switch Holder
It attaches on the side of the button holder and the tact switch is mounted on it.

Schematics

Schematic
Connect as-is. Sorry if it's messy.
Schematic bb 2ok5rjtgon

Code

Arduino Mega CodeC/C++
Copy and Paste for the Arduino Mega.
#include <Wire.h>
#include <SparkFun_APDS9960.h>
#include <LiquidCrystal.h>
#include <Servo.h>

#define LARGE_AMOUNT 4000 //time to dispense candy in ms
#define SMALL_AMOUNT 2500

LiquidCrystal lcd(12,11,5,4,3,2);

Servo auger;

SparkFun_APDS9960 apds = SparkFun_APDS9960();

uint8_t proximity_data = 0;
int LB = 6;
int RB = 7;
bool LBS = false;
bool RBS = false;
int candy_amount = 0;

void setup(){
	if ( apds.init() ) {
    Serial.println(F("APDS-9960 initialization complete"));
  } else {
    Serial.println(F("Something went wrong during APDS-9960 init!"));
  }
  if ( !apds.setProximityGain(PGAIN_2X) ) {
    Serial.println(F("Something went wrong trying to set PGAIN"));
  }
  if ( apds.enableProximitySensor(false) ) {
    Serial.println(F("Proximity sensor is now running"));
  } else {
    Serial.println(F("Something went wrong during sensor init!"));
  }
  lcd.begin(16,2);
  lcd_reset();
  lcd.print("Initializing");
  auger.attach(9);
  pinMode(LB, INPUT);
  pinMode(RB, INPUT);
  Serial.begin(9600);
  delay(5000);
  lcd_reset();
  lcd.print("Running");
  delay(4000);
  lcd_reset();
	lcd.print("Google Powered");
  lcd.setCursor(0,1);
  lcd.print("Candy Dispenser");
  auger.write(90);
  auger.detach();
}

void loop(){
  int state = analogRead(A0);
  LBS = digitalRead(LB);
  RBS = digitalRead(RB);
  
	if (state > 60 || LBS == true || RBS == true){
  Serial.println("active");
  Serial.print(LBS);
  Serial.print(",");
  Serial.println(RBS);
  LBS = false;
  RBS = false;
  delay(1000);
  lcd_reset();
    lcd.print("How much candy?");
    lcd.setCursor(0,1);
    lcd.print("A Little   A LOT");
    while(LBS == false && RBS == false){
      LBS = digitalRead(LB);
      RBS = digitalRead(RB);
    }
    if(LBS){
      candy_amount = SMALL_AMOUNT;
    }
    else if(RBS){
      candy_amount = LARGE_AMOUNT;
    }
  while(proximity_data != 255){
  if ( !apds.readProximity(proximity_data) ) {
    Serial.println("Error reading proximity value");
  } else {
    
    lcd_reset();
    lcd.print("Waiting for cup");
    lcd.setCursor(0,1);
    lcd.print("Distance: ");
    lcd.print(proximity_data);
  }
  delay(400);
  }
  lcd_reset();
  lcd.print("Cup found!");
  delay(1000);
  
  for(int x=5;x>0;x--){
    if ( !apds.readProximity(proximity_data) ) {
    Serial.println("Error reading proximity value");
  } else {}
    if(proximity_data != 255){
      lcd_reset();
      lcd.print("Please replace");
      lcd.setCursor(0,1);
      lcd.print("the cup");
      delay(2000);
      while(proximity_data != 255){
  if ( !apds.readProximity(proximity_data) ) {
    Serial.println("Error reading proximity value");
  } else {
    
    lcd_reset();
    lcd.print("Waiting for cup");
    lcd.setCursor(0,1);
    lcd.print("Distance: ");
    lcd.print(proximity_data);
  }
  delay(400);
  }
  lcd_reset();
  lcd.print("Thanks for");
  lcd.setCursor(0,1);
  lcd.print("replacing it");
  delay(1000);
    }
    else{
    lcd_reset();
  lcd.print("Pouring in: ");
  lcd.print(x);
  delay(1000);
    }
  }
  lcd_reset();
  lcd.print("Pouring candy...");
    delay(1000);
    auger.attach(9);
		auger.write(20);
		delay(candy_amount);
		auger.write(90);
    auger.detach();
		
   lcd_reset();
   lcd.print("Enjoy!");
   delay(4000);
   lcd_reset();
 lcd.print("Google Powered");
  lcd.setCursor(0,1);
  lcd.print("Candy Dispenser");
  proximity_data = 8;
	}
}

void lcd_reset(){
	lcd.clear();
	lcd.setCursor(0,0);
}
Particle Photon CodeC/C++
Copy and Paste
#include "application.h""

int pin = 7;
char charBuf[50];
int out_pin = 5;

void setup() {
    pinMode(out_pin,OUTPUT);
    pinMode(pin, OUTPUT);
    Particle.function("give_candy", candy);
    Serial.begin(9600);
}

void loop() {

}

int candy(String command){
    command.toCharArray(charBuf, 49);
    char number[6];
    sprintf(number, "%c" "%c" "%c", charBuf[0],charBuf[1],charBuf[2]);
    int length1 = (int)number[0] - 48;
    int length2 = (int)number[1] - 48;
    int length3 = (int)number[2] - 48;
    
    int length = length1 * 100 + length2 * 10 + length3;
    digitalWrite(out_pin,HIGH);
    delay(100);
    digitalWrite(out_pin,LOW);
    
    for(int x=0; x<5; x++){
        digitalWrite(pin,HIGH);
        delay(length);
        digitalWrite(pin, LOW);
        delay(length);
    }
    return 0;
}

Credits

Download
Arduino “having11” Guy

I love creating cloud solutions that can interact with hardware along with using Arduino boards and Raspberry Pis to create new projects.

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

Headless Voice Activated Google Assistant on Raspberry Pi
Intermediate
  • 400
  • 7

Full instructions

Turn your Raspberry Pi into a Google Assistant.

Pulse Train HAT for Raspberry Pi Mecanum Bot Example
Intermediate
  • 1,246
  • 19

Full instructions

With this example, we show how to use the PTHAT and wireless Xbox controller to control a Mecanum Bot.

Blynk GPS Tracker
Intermediate
  • 19
  • 1

Full instructions

Simple GPS tracker using a Particle Photon (or Electron) and an EM406 GPS module with location visible on Blynk app map.

Pool Buddy
Intermediate
  • 1,495
  • 11

Work in progress

Monitor and log water quality (pH & ORP) and temperature from everywhere.

Smart Garden
Intermediate
  • 1,992
  • 17

Smart Garden is a plant environmental monitoring system.

DIY Vintage Spotify Radio Using A Raspberry Pi
Intermediate
  • 1,174
  • 11

Full instructions

Make your own vintage radio that streams Spotify, Google Play Music, SoundCloud and your own local music!

ProjectsCommunitiesTopicsContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login
Feedback