Month: January 2014

Blast from the past, My first coding project

I’m going to be honest here, I’m updating for the poor HR representatives that have to look at this blog for research after reading my resume at the GT career fair. In order to give some personality to this mysterious author who’s thoughts you read so diligently, I have decided to write about my first real coding project!A little background, when I graduated high school, I KNEW I wanted to do Aerospace Engineering. Until orientation at GT (we call it FASET) at which point I decided I KNEW I wanted to do BioChemistry. I believed that new path was the one for me until I took a wonderful class in Computer Science. At that point, I was sure that I had been hasty before, so I waited an entire semester before realizing that this time I REALLY KNEW. So what magical class was so powerful as to make me change majors again and stick with it?

It was Jython

For the uninitiated, Jython is a special blend of the programming language “Python” and some common java libraries. This allows beginner programmers (like myself at the time) to create very clean object-oriented python code in a neat IDE with a console,  and makes visual animations easy.

Jython code in the JES IDE

Jython code in the JES IDE

Jython was my first experience in coding, and it saw my first “Hello World” program, very basic number programming, image manipulations, and eventually animations.  The final project of this class used a unique aspect of Jython called “Turtles”.  You see, in the parallel version of this class which was required for CS majors, the end of the class involved controlling small robots with attached pens around in a pattern. These robots were called ScribblerBots, but they were relatively expensive. Instead, our class made use of the visual libraries provided by java to create small turtles in a picture. The turtles could then be commanded just like the robots, moving and drawing lines, but they could also be used for animation.  By using an array of turtles, each with a certain job, the turtles could change the background to create animation, they could change colors to act as an animated object themselves, or they could drop images on to the screen to create new visual objects.

Our Final Assignment

We were expected to use everything we learned throughout the year to create an animation which satisfied several requirements. As best I can remember them, the minimum  requirements were:

  • Use at least 4 different turtles on the screen at the same time
  • Make at least one turtle change color and size
  • Make a turtle draw, move, stop drawing, and move again
  • Use a randomizer to change at least one attribute of one turtle.  (I went a little crazy on this one)

Beyond those requirements, the assignment was very free form, and we were encouraged to be creative. I took it to heart.

What Horror Hath I Wrought?

Screenshot of the animation

Screenshot of the animation

Pokémon. Registered copyright or trademark or whatever, but let’s be real, it was Pokémon. My goal was to recreate a Pokémon trainer encounter and subsequent battle. For those that have a JES environment (get it here) you can download my code and watch it with full randomness at the usual place. Feel free to download and parse it to see how it works, but remember this is my first real coding work.

For those who have no interest or capability to parse the code and execute it natively, I have a screen recording of the execution.

I hope you enjoy the movie and stay tuned for more!

BartenderBot, As Promised

The Pi Bar

Don't touch

Pi Bar in its current state

If you have read my previous posts, you already know I have been working on a BartenderBot and not much else. If this is your first post to read, I have news for you: I’m building a BartenderBot! The picture doesn’t look like much, so let me break it down for you.

What Is It?

This is a robotic bartender that will dispense simple drinks automatically. One of my hobbies is bartending and mixology, so fusing that hobby with my passion for making things just seemed right.  The idea began as the desire for a robotic dispenser, mixer, and recipe book, and is well underway.


Raspberry pi

Raspberry pi

The whole thing is run by a Raspberry pi. These boards are amazing, and for ~40 bucks you can have your own tiny fully-functional computer and control board. In my case I run Raspbian (a debian linux distro built for Raspberry pi) on the pi for full functionality. More on the OS and software in a minute. For now, just know that the software sends commands to General Purpse Input/Output (GPIO) pins on the pi. These pins are jumped to a 3-to-8 demultiplexer. For those of you who are not familiar with this circuit, it takes in 3 selector bits to represent numbers 0-7, and one enable bit to turn on the output selected by the other 3 bits. This allows me to turn 4 pins in to signals with no worry of simultaneous dispensing. From the deMux board the signals travel to a 16-channel 12V relay board.

Relay Board

Relay Board

This awesome Sainsmart board allows me to switch 16 (though I’m only using 8) valves which required 12V/500 mA each using 4 pins on a 3.3V pi! A single 12VDC power source is connected to the board in the form of an AC/DC converter and the power is distributed only to the active relay as chosen by the input pins. The board also prevents back EMF from frying my pi by using opto-isolators, so you know, that’s nice.


The custom drink screen, displaying the recipe for a Sex on the Beach

The custom drink screen, displaying the recipe for a Sex on the Beach

Now, a computer with the power to control fancy dispensers is not very useful if the user has no control over the computer. As I mentioned earlier, the pi has a full linux OS on it, and that could in fact be used to control the machine. However, through a small poll of my friends it was determined that no one wanted to type “echo 1 >gpio(xx)/value” every time they wanted to turn on a valve. Instead, I have coded a Java program which manages premade recipes, a custom drink creator, and a settings screen to change which recipes can be made.  The Java program is loaded on to the pi as a jar, and runs at startup, initializing the pins and displaying a custom UI. The UI can be exited via a secret button, but for the most part, the UI should be the only local interface to the pi. My hope is to add a touchscreen which can be used to make drinks without a mouse or keybord, so the entire UI is made touchscreen-friendly.


What’s Next?

I am currently taking a class in which I am required to prototype a machine for a semester-long project, and have decided to make this my project. As such, I will be adding features to meet requirements, but will also have access to way more sophisticated equipment than my home prototyping lab. Hopefully by the end of February I will have base functionality and a frame, but I will be adding sensors, beautifying the UI, and refining the program until April. I will post again once I have a functional prototype, and any Atlanta are alcohol/robot enthusiasts should come give it a test drive.



The Word of the Day is List!

I am still working on a post about the Bartenderbot project (gonna be a big post) so in the meantime, I’d like to talk to you about Lists.

Quick background for the non-programmer audience, bear with me programmers.
There are many ways of storing data in computer science. These ways of storing are called “Data Structures”. They range from stacks and heaps to arrays and lists. The ones I will be discussing today in the most detail are arrays and lists. Arrays are ordered lists, almost like a row of numbered boxes each holding some data. This allows data to be accessed according to its position in the array. Arrays are notated with square brackets and indexed by an integer in those brackets.

int[] arr;
int x = arr[i];

Because of their ability to store and load data quickly, arrays are quite common, and my code used to be full of them. That is until I discovered the full potential of lists.

Arrays have a fatal flaw. When an array is made, it has a set length. That is to say if you want to add data to a full array, you need to create a new longer array, copy all the old data in to the new array, then add the new data. Lists avoid this flaw.

List is actually a misnomer. Java.Util.List is an abstract class, meaning it cannot be instantiated. Rather, you must used a class that inherits List. My favorite such class is Java.Util.ArrayList. ArrayLists use the afforementioned arrays as backing structures, but takes care of all the messy array reassignment internally. So if you have a full ArrayList, and you want to add one more object, you only need to call list.add(object); and the list will append the new object.

My past week has been centered around finishing the software for the Bartenderbot. This software relies on collections of Ingredients, Instructions and Recipes, which I had previously set up as arrays of the corresponding objects. After writing:

Instruction[] temp = new Instruction[instructions.length+1];
for(int i=0; i<instructions.length; i++){
    temp[i] = instructions[i];
instructions = temp;

for the nth time, I tried switching to lists.

After reassigning variables throughout the code, it was amazing how many lines I saved. I turned for loops into foreach loops, arr[i]’s into .get(i)’s, and the previously shown add functions into .add()’s. So if you haven’t already, go make some lists and correct the overuse of arrays.

Java Drinking Games

As promised in my intro, I am going to write a little about an annual challenge I give myself: Spring Break Drinking Games. It started out of necessity. We were on spring break, thinking of late night fun activities, and decided on a drinking game. We searched for cards to play Circle of Death, only to find that no one had brought cards and it was much too late to go to a store.  Having just recently learned my first java coding principles, I whipped out my laptop and spent a couple hours simulating our card game. The rest of my party loved playing on a screen so much that the tradition continued the next year (this time with Horse Races).

Circle of Death

Screen shot of Circle of Death

Screen shot of Circle of Death

Circle of Death was quick and dirty. I had just started learning code, and had no idea of good code practices. I manually wrote many things that should have been looped. I included way too many things in one class, and I basically eliminated any possibility of future alteration. But it works.

I used a CardDeck Class with variables for each image to draw a random card, then add that card to the “used pile”.

I then made UI classes (my first attempt at java UI) and a gameLogic class which took the drawn card and kept track of what was happening in the game.

If you want to look at the code (or play the game) my gitHub has all source code and a runnable jar file here.

Horse Races

Horse Races UI

Horse Races UI

By this point, I had gotten a little bit better at UI, so this game didn’t take nearly as long, and is much more visually appealing. On the backend, I switched to using arrays to store images and programmatically create Card objects, rather than randomly drawing an image. I also created a set of functions to simulate real card deck usage (splitting, reshuffling, and separating out specific cards). This allows me to use my cardDeck class for other applications, opening the game up for modification.

To take a look at these games, download from the gitHub link here.



My next couple posts will be about my current project-in-progress: a  robotic bartender.

Blogging about projects is itself a project…

Hey all, I’ve decided to give this blogging thing a try in order to catalog my thoughts and progress on various coding and  prototyping projects.

About the name

I am a Computer Science Major at Georgia Tech, a professional developer, a homebrewer, and a bartender. I have many hobbies and diversions, but two of my greatest passions are programming and alcohol culture. I enjoy everything about mixing drinks, creating new beers, and programming throughout. As such, I felt it was only fair to honor my passions in the title to this blog, as well as in many of my projects (see future posts about Java drinking games, robotic bartenders, and the like).

What to expect

If you are reading this line, you have about the attention span necessary for my posts. I will be updating on an approximately weekly schedule, typically with an update on a current project containing a code snippet or design blueprint alongside a blurb of what it does or why I need it. I will try not to bore you with detailed analysis of the efficiency of certain methods, but it may help to have some understanding of programming or electronics. That being said, I will include plenty of pretty pictures and write in my clearest English (as checked by my English major girlfriend).

So grab a drink, settle in and enjoy the blog!