Let's Make Robots!

How to connect stuff?

I recently had the great idea of building a robot.


So I went and bought this:


and a PIC 18F4550 IC to go on it, as well as some wires and a couple geared motors and a servo. So... How do I connect all the stuff together so that it works?


I have never done anything with electronics before in my life.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Well, to be perfectly honest a PIC microcontroller is usually a bad choice for someone who's just starting out. I'd recommend checking out the Start Here robot - that should give you an idea of how to put together a basic proper robot starting from scratch.

I was going to follow that guide but the problem was sourcing the required parts locally. I guess I will get that stuff off the net to build the starter robot now but I had hoped I could buy some gear locally and just go nuts. Why is it that a PIC microcontroller is a bad choice? I am completely new to electronics and building robots but I'm definitely not new to programming (very competent C/C++ skills).

The stuff I did buy was kind of expensive too so I would like to use it. I understand that I have to attach the wires from the motor to the board so that the microcontroller can make it go and stop but where do I connect it? How do I determine the correct place?

Is there a book or website you could recommend that will explain what all the little do-dads and knoby bits are that I just spent an hour souldering are? I want to understand why I put this little blue guy here and why I put this guy here and what this thing here does etc etc.

Any help is appreciated.

Although PICs can be programmed in C, you'll find there are lots of little tricks and differences that will take time to get the hang of. I'm also certain that if you can order from Jaycar then you'll be able to find a local enough source for other microcontroller options. The main difference between programming C on a micro and C on a PC is that you virtually always have direct and absolute control over the hardware of the device, whereas the opposite is true for a PC. On a PC there are so many levels of abstraction between the C program and the physical hardware that the code is almost its own entity. On a micro however the code and the hardware are very closely interlinked, failing to understand this will cause a lot of frustration when seemingly perfect code goes haywire.
A solitary PIC micro is a 'bare' microcontroller, i.e. it does not have any supporting hardware. You'll typically need to add a voltage regulator, resonator (optional if you don't need a fast clock or accurate timing) and filtering capacitors before the micro will even perform basic tasks. To run something like a DC motor you'll need at least a basic transistor driver, or preferably a proper H-bridge IC or similar. Do not try to power a high-current device like a DC motor directly from your PIC, most of the pins can only source/sink 20mA current and the micro will likely be damaged if you attempt this. In any case 20mA isn't enough to make most motors do anything exciting.
Long story short, you may want to find an Arduino or similar microcontroller that already has a suite of supporting hardware built around it. If you're dead set on leaping straight into PIC development that's fine, but I think you'd benefit from an easier introduction before working your way up to a more professionally targetted (and less forgiving) platform.

Jaycar doesn't offer much info on that programmer you picked up, and since its a Jaycar product I can't go elsewhere for more info. Basically what the programmer does is supply power and various logic level voltages to the target PIC, while the rest of the board translates the incoming data from the PC into a serial format suitable for flashing into the PIC's ROM.

This Wikibook is definitely worth a look through if you're unfamiliar with common electronic components. Most electronic components are used in a wide variety of ways, so its more important to understand their properties and behaviours than to simply say 'this component does this job'. You'll understand what I mean easily enough =)

Here is the datasheet for your PIC micro. This is a fantastic resource; Microchip writes a good datasheet, and they've got other useful items on their website too.

Ok, I think that's enough Wall of Text™ for tonight =)
I'll be around if you have any questions, and there are at least a few other PIC users floating around LMR who can help out too.

Thanks for you help mate. Walls of text are good.

So am I right to say that the little kit I bought if just to program the code onto the PIC and I would need another one to put the PIC into afterwards that has all the required stuff for motors etc?

The 4550 is an awesome chip. I mostly use the 452 which is the non-USB capable version of it. Now, a question about the programmer you bought. Do you know if it can be interfaced to MPLab? That's Microchip's free development environment. If so, that's going to simplify things greatly. I've got some good experience with PICs and writing C code for them, so feel free to PM me with questions. : )

You're probably going to want to pick up a breadboard. This allows you to construct circuits without permanently attaching (effectively ruining) parts like your PIC chip. At the very least to run your chip, you are going to need a battery, a voltage regulator and a capacitor. A good combination is a 9V battery coupled to an LM7805 voltage regulator. This has three pins, and regulates the voltage at a constant 5V. The capacitor outlined in the datasheet (I think it was provided above) states that you should have a 100uF (micro farad) capacitor to reduce ripple from the power supply. 

I'll let you digest some of this before going on...we'll get you started eventually! 

- P 

That appears to be a programmer and Microcontroller. I have to agree with telefox, starting with a PIC or ARM processor into the world of uC programming is kind of like trying to write a AAA class directX 3D game engine with shader support before you know how to create a window.

 Most other microcontrollers, the Arduino being a good start, come as a development board with everything you need to get going right away.


As well while Microcontrollers are a great way to save ALOT of discrete logic components, they need support too. Think of the pic as your PC's CPU, without the motherboard and supporting hardware it cant do much. With uC you get to choose, design and implement the tailored support hardware for the processor.

an example is the motor controller circut, depending on the motors you wish to control this could be as simple as adding a L293 IC to your robot and using three I/O pins from the MCU to tell it what to do.

Using the PC anaolgy the motor controller becomes like a sound card, it gives the uC a new level of functionality.

Now getting into uC is not easy, trust me I have over 20 years experience in professional software engineering and can program fluently in 24 different programming languages. When I jumped into this pool I figured that the software side would be a walk in the park, so I purchased several AtMega168's and a serial programmer. I had some electronics experience, i.e. I could read a schematic and solder :), basically after asking ALOT of questions trying to figure out the AVR's registers, pin modes, and bit based operations (It had been awhile since I had to use these), one friend finally screamed YOUR STARTING WITH THE WRONG UC. :) it was a little dissheatening I had spent alot of money on the AVR's, he guided me to the arduino, which was the correct place to start, I made progress quickly and then was able to go back, better understand the AVR system use them proficiently and now I am learning how to use ARM processors.

It is a long process and probably one of the most expensive hobbies available, but it is worth it and it is very rewarding.


Just my wall of text :)

Thanks guys you've all been a great help. I think I'll start reading some material first so that I understand what it is that I'm doing, then I'll come back to what IC I should be using. I'll let you all know my progress.

Is it worth the time to look at building transistor radios etc etc to get my head around the electronics first?

Everyone is different but all the successful builders Ive seen on here started with an IC and added a blinking LED, then added a servo or a motor. They slowly built up to making a robot and by doing 1 part at a time learned how it all worked. All the people I have seen that took someone's code and tried to make it work got frustrated and used the first method or never went any further.
Just a quick note about transistor radios - in my personal experience I've found that they're easy to built if you just copy a schematic, but pretty hard to build a good one from your own design. All the RF and audio signal theory is probably just going to be an extra headache at this point.
Since you're obviously familiar with PC programming, I'd suggest sticking with primarily 'digital' circuits for now. Like Jklug said, try making an LED turn on and off once per second with a microcontroller. Then try to make a 7-segment display count from 0 to 9 incrementing once per second. Next hook up a servo and make it point left, up, right, left, up... Something along those lines anyway.
Microcontrollers actually make learning about other electronic circuits quite easy, because the controller (once you can program them effectively) basically acts like a little avatar, carefully controlling and organising the circuit according to your instructions. The addition of a microcontroller basically breaks down a large interlinked circuit into a whole lot of smaller modules, so you only have to worry about designing/building/implementing one module (i.e. servo control, sound buzzer) at a time, which is great for learning purposes.
Okay, so once I've got my programmer with my IC working, as in being able to program it, I should move onto using a blank board and adding things one step at a time until I've completed my 100 strong army riding a fully autonomous death star. Right?