My edible email notifier is fully functional! It successfully indicates the new number of emails by spinning and dropping M&Ms into a glass. Then, once the emails have been read, an LED lights up to indicate that you may eat the M&Ms.
The coding was in two parts: a Python code and an Arduino code. This was my first time working with python, and it was an interesting process of trial and error. The code consisted of: checking if the arduino is plugged into the computer, then logging into Gmail (with provided email and password), checking the number of unread messages, sending a certain letter to the arduino indicating the number of emails and repeating it every 20 seconds.
Once the arduino receives the certain letter, it decodes the letter to a number (I have not been able to figure out how to get python to send just a number to the arduino). It compares the number of unread emails to the previous number of unread emails and does one of three things: if unread is greater than previous, it steps the motor forward; if unread is the same as previous, nothing happens; and if unread is less than previous, the LED lights up and indicates that you may eat the M&Ms because that means you read your email!
The stepper code is fairly simple. Since the motor I’m using has 200 steps per revolution, each new email moves the stepper -50 steps, or 90 degrees clockwise. The stepper know how many steps by doing the calculation: -50 times (the current email number minus the previous email number).
I have some minor additional adjustments that I’ll make in the future, including attaching the stepper motor to the base, cleaning up the python code and potentially laser cutting a better looking dispenser.
Here’s the final video showing the Edible Email Notifier in action!