Software Design
The final code for this project can be found on this GitHub.
This section runs in parallel with the firmware section, and if you haven't checked that out yet, do that first to get some context on the code!
Iteration 1: Arduino with serial monitor
Initially, to ensure that we had a rough code framework to test our parts on, we coded out an interface using the serial monitor. This code essentially worked as follows -
- The user would enter a message on the serial monitor specifying which drink they want.
- Depending on the message, the corresponding function would be called.
- In the function, the appropriate digital signals would be sent for a fixed amount of time to open a valve to pour the drink.
- After pouring the drink, the user would be sent a message on the serial monitor saying that their drink is poured.
- The loop would repeat.
This is essentially the same framework we carried throughout the project. Initially, we had also planned on including a function to calculate the correct amount of drink to be poured based on flow rate and water pressure, but we discarded that idea since we didn’t have the mechanical infrastructure set up to test it appropriately.
Future iterations basically involved modifying steps 1 and 4 into a full-fledged user interface.
Iteration 2: Arduino and Raspberry Pi setup with touchscreen
In this part of the project, while there was a lot of setup, changing laptop settings, and integration, there was no actual coding since we never got to the stage of creating an interface between the touchscreen, Raspberry Pi, and Arduino. Most of the coding in this project happened in the final iteration of our design.
Iteration 3: Teensy User Interface
Using the framework we had created in Iteration 1, we expanded on the touchscreen interface using Stan Reifel's library that we described in firmware. Using this, buttons and panels on the touchscreen could be coded by using objects to specify each component. In this way, an entire screen would be coded out in just one line of code, and each object was linked so that we could cycle between different menus. This library was so incredibly convenient that the part of the project that had previously taken us two and half weeks was solved from scratch in just 5 hours! It speaks for how powerful having the right library can be.
We linked each of the menus created using the library to functions to pour each of the drinks - each of these were essentially copied over from Iteration 1 due to the way we had separated out our code. These allowed the Teensy to communicate with the valves appropriately when the necessary button was tapped on in the touchscreen menu. However, one of the features we didn’t find the time to integrate was releasing multiple drinks at the same time to create a true ‘Drink Mixer’. While it was a simple addition of a few lines of code from the software side, we were not able to test the mechanics of pouring multiple drinks in time. In theory, there is nothing stopping the our machine to pour multiple drinks at the same time with the way it’s currently constructed.
As an extra treat, we integrated an LED strip into our machine. If you haven’t already noticed from our demonstration video, this simple addition made a significant difference to the aesthetic quality of our machine. The one constraint was that we couldn’t run the LED and the touchscreen interface process simultaneously, so if you notice from our video, our LEDs only change colors/flash when the touchscreen is starting up or frozen on a particular screen.
Once again, the code can be found on this GitHub.