Android Things A.I. Candy Dispenser

Hardware components:
Pi 3 02
Raspberry Pi 3 Model B
× 1
11868 00a
Raspberry Pi Camera module
× 1
Smart Candy Dispenser
× 1
Serial Display 20×4 LCD i2c
× 1
Fairchild semiconductor pn2222abu. image
General Purpose Transistor NPN
× 1
Momentary Arcade Button
× 1
Mfr 25frf52 10k sml
Resistor 10k ohm
× 1
12002 04
Breadboard (generic)
× 1
11026 02
Jumper wires (generic)
× 1
Software apps and online services:
Logo things yummo7uv2y
Google Android Things
Google Cloud Vision API
Google Android Studio
Hand tools and fabrication machines:
09507 01
Soldering iron (generic)

 

Android Things A.I. Candy Dispenser

STORY

The project

The Android Things A.I. Candy Dispenser: here’s a demonstration of how to create a “smart” candy machine. The device is a game that asks the user for a specific thing like a bird, dog or cat, and the user should show a photo of that thing in the predefined time to win candies.

This project uses a button to interact with the user, obtains images via a camera peripheral and a modified electric candy dispenser being controlled by a GPIO with a transistor.

When the user takes a picture, it processes the image data using Google’s Cloud Vision API, which returns annotations and metadata of the image. This info is used by the device to see if it matches what was requested. When we have a match, the motor of the candy machine is activated and give the user the prize.

All users interface is presented in a Serial i2C 20×4 Display.

The device (Raspberry Pi 3B) is running Android Things dev preview. It has a camera connected to take pictures, a 20×4 Serial i2c Display to show the “little” game state, a arcade button to interact with the game and a simple NPN transistor to activate the candy machine DC motor.

The core of the project was deeply inspired by the Doorbell

https://github.com/androidthings/doorbell

This code sample was made in Android Studio, using Kotlin Language and Google Vision API to classify the image. Please also note that this has only been tested on a Raspberry Pi 3, but should work on other compatible boards too.

Getting Started

You will need to setup your environment to run and program the Raspberry Pi using Android Things. All the content to get started with Android Things can be found at the official website. You should follow this to run this project:

https://developer.android.com/things/preview/index.html

After that you should have a Raspberry Pi running Android Things and with the proper network setup to program it.

Pre-requisites

  • Android Things compatible board
  • Android Things compatible camera (for example, the Raspberry Pi 3 camera module)
  • Android Studio 2.2+
  • “Google Repository” from the Android SDK Manager
  • Google Cloud project with Cloud Vision API enabled

The following individual components:

  • 1 push button
  • 1 resistor
  • 1 electric candy machine
  • 1 NPN transistor
  • 1 diode
  • 1 Serial i2c 20×4 Display
  • jumper wires
  • 1 breadboard

Schematic of Android Things A.I. Candy Dispenser

More detailed schematic and code can be obtained at the end of the project description on Github.

Read More: Android Things A.I. Candy Dispenser

Scroll to Top
Read previous post:
Antique Radio into an Airplay Speaker

My father-in-law is a musician and a lover of mid-century modern design. I have an obsession with tinkering. Somewhere in...

Close