Friday, 2 October 2015

Simple Arduino

I've been meaning to learn something about microcontrollers and hardware prototyping forever but there just never seemed to be the time. Fortunately, time was created at a recent PLIBMTTBHGATY meetup when a friend offered to bring a load of unused Arduino "bits" for me to play with. Interestingly, everyone I know owns at least one Arduino but only two of them actually know how to use it properly.

Getting going turned out to be quite easy, which was a relief as starting from pretty much no knowledge (I learned some basic electronics at school a long time ago but that's about it) is usually a pain. A huge thanks to Neil for answering some of my very basic questions. I'm intending to write a few "getting started with hardware stuff" posts as I continue learning and I'll write up some of what he taught me in the hope it will help others get going.

Box moving in a rectangle

My first creation of interest was a box moving in a rectangle on an LCD screen.



This was mostly a programming exercise as wiring up the circuit was just a case of following a diagram exactly but it was useful to learn the basics of syntax and how to push a program to the Arduino.

Building blocks to make this:

Button switches between LEDs

Next up, a circuit which switched from a red light to a green one while a button was depressed.



This was the first circuit I designed myself, using the knowledge gleaned from a few other tutorials.

Building blocks to make this:

Bouncing box game

Finally, I was challenged to make a simple pong-style game. The box travels left to right. If the button is pressed as it reaches the end, it bounces back and the player gets a point. Repeat until the button is not pressed correctly and the game resets.



A more complicated circuit here, requiring a second breadboard and many of the Arduino's pins.

Quite a lot of work went into coding the logic of this game. The initial version allowed the player to keep the button pressed down and the box would bounce indefinitely so I changed it to have the game reset if the button is pressed too early as well as too late.

Building blocks to make this: