Tech Talk Logo

Making Robots is Easier Than You Think

Many people want to automate a task, but they just don’t know how to go about it. Well, it’s never been easier to make an electronic device to do something for you, and it is getting easier all the time. The cool thing is, even if it doesn’t walk and talk, it is still considered a robot.

Traffic Lights and Music

Recently, I picked up a traffic signal at an auction. I didn’t know I wanted it until I saw it sitting on the table. When I got it home, the problem was getting it to do what I wanted it to do, which was to cycle through the lights and flash to music.

This task might seem impossible for people that have no knowledge of electronics to do, but there is a huge push to get kids interested in computers and electronics, so there are devices out there that are made to be easy enough for kids to work with, don’t cost a lot of money, and make the task of doing automated tasks much easier. In fact, there are companies out there that cater specifically to the “maker”, and they exist for just about every kind of thing you might want to automate. From controlling motors to lights to the temperature, there is a module that plugs into a microcontroller or computer. In fact, if you just want to play with simple things, you can buy micro-controllers from China for less than $3 a piece.

Arduino

One of the devices that can be used is a micro-controller break-out board called an Arduino. There is a company that makes these boards that is the official “arduino” brand, but it is open hardware and software, so anyone can produce a board just like they do, and the Chinese pump them out like crazy for very cheap prices. It is unlikely that you won’t be able to find the one that does what you need for less than $10, and usually less than $5.

One of the devices that can be used is a micro-controller break-out board called an Arduino. There is a company that makes these boards that is the official “arduino” brand, but it is open hardware and software, so anyone can produce a board just like they do, and the Chinese pump them out like crazy for very cheap prices. It is unlikely that you won’t be able to find the one that does what you need for less than $10, and usually less than $5.

A microcontroller is a self-contained chip that has pins that send out a voltage to those pins and recognizes when a voltage is applied to pins based on things like a switch being flipped, or a sensor tripping. While it may sound like a simple thing to do, the fact that you can program those pins to do what you need to do is what makes them so powerful. You can flash small little LED lights, or turn a motor on and off. You can even send a pulsed signal that will change the speed of a motor. An Arduino board would make the traffic signal I got run like a dream. I didn’t use that though.

Raspberry Pi

There are a boatload of new computers on the market that sell for very little but are actual computers that you could use as a desktop if you needed to. The Raspberry Pi was the first of these, and they sell for around $35. It’s about the size of a deck of cards, can run on a television, or without a display, is powered by a micro-USB adapter like you would charge your phone with, and has input and output pins like an Arduino does, but instead of using a microcontroller, it uses a much more powerful microprocessor.

The Raspberry Pi is what I chose to run the traffic signal because I wanted to be able to use a web interface to change its timings. If all I wanted to do was make a static device that flashed the lights and flashed them to music, I would have been better off using an Arduino, as they are quite a bit cheaper, a bit smaller, and just as capable at those tasks as any computer.

Here is the current state of my controller.

Tech talk1

The board at the bottom is a solid state relay board that can be gotten on eBay for about $15. That board allows you to turn up to a 2 amp load on and off using a micro-controller or Raspberry Pi. It takes a 3.3V signal on one side and allows the power to pass through on the other side. This is how I am able to control 120V AC lights.

The device in the middle is the Raspberry Pi. That is running the lights, listening to the sound sensor that is buried under the relay module, and controls the text on the little LCD screen there, so I can tell what mode it’s in, and what its IP address is, in case I want to connect to it over the network.

The final board in the back there is simply a switch I made with a single transistor so that the LCD will shut down, otherwise, it is on all the time the Raspberry Pi is on.

The cool thing about both the Arduino and Raspberry Pi is that there is a huge community of people that can help you for both products. If you have any question, it has likely been answered, and if not, people are very friendly and willing to help. This is much of why these two boards are so popular.

What if you don’t like all the wire?

After putting this together, I was going to put it in a project box and call it a day. I decided I hadn’t wasted enough time on it yet though, so I decided to make what is called a “hat” for the raspberry pi. I created a schematic using a free piece of software called KiCad, designed the board and placed the parts, and then created the files necessary for a manufacturer to build the board. I will be getting 10 boards in the end for around $15. Given how much of a pain it is to make your own boards, I find that to be an excellent deal. The parts to populate the boards with are around $5, so if I didn’t do anything stupid, I will have 10 of these boards I only paid about $6.50 a piece for.

Here’s a 3D model of the board I designed:

Tech Talk2

This has a header on the bottom side of the board to connect directly to the Raspberry pi, and it has headers for connecting the LCD, sound sensor, and mode switch. It will clean up a bunch of that clutter, and it will be an accomplishment, as I have never built a hat for a raspberry pi before.

Before you worry that this is too difficult, I have to tell you, it isn’t that hard. A little basic electronics knowledge, and access to YouTube, and you will be able to make boards like this in no time. I learned how to make these boards in less than a day. Granted, I have a bit more than a passing knowledge of electronics, but that doesn’t mean I’m an engineer.

Lots of Small Things Make the Whole

Remember this little thing, and you can do electronic circuits too. Lots of small things make the whole. The board I made above is really not very complicated. I knew that I would be trying to trigger the relays with 5 volts, but the raspberry pi’s pins use 3.3V logic, so I needed to incorporate a logic level shifter. I found some schematics online for one and incorporated it into my schematic 5 times. Once for each light, I will be controlling. I also wanted to have an LED come on when the relay kicked on, so I put a resistor and an LED on the 5V side of the logic shifter. Finally, I still needed to switch the power on and off to the LCD, so I put the transistor I had on the small board in the first image on the board. In reality, the hardest part of this entire thing was finding out the best place to put components so I could get traces to places I needed them.

The final thing I did was to program the raspberry pi to have a web interface that allowed me to control it. I shared this on Githubas well, so anyone that wants to see the software is free to look at it, download it, modify it, etc.

Anyway, I hope you might consider working on a robot of your own. It is quite fun and satisfying.

If you are interested in doing things with microcontrollers and single board computers, there are many places to go. adafruit.com, sparkfun.com, pololu.com, and a bunch of other websites are dedicated to hobbyists working with electronics. They have boards, kits, wires, and electronics to do all the things you might think of doing, and they all have resources to help you learn how to use them. All you need is the interest to learn.