Al's Robotics....



Site Index
Site Index

Robotics Shop

Rambo Auto Tools

Robux Project





Robotics Events


My Robots

Linux Computing
Reading Books

PIC Micro


Latest News

new information added to the Robux Project Pages click here for more info

PIC Micro Robot


The PIC Micro robot code named KTX1 has the ability to move around unaided by human intervention custom navigating it's surroundings. When it feels an obstacle with it's sensors it backs off immediately and changes it's direction and continues it's search across the vast barren landscape that is your living room floor. The program also contains information that will make the robot dance on a flat surface (nice!). It's amid at the starters that are getting into PIC programming and want the PIC to control a robot but don't quit know how to do it. The project uses a PIC 16F84 to control the robot and all the code is in machine code (so non of that PIC basic stuff here). I used the wizpic software to make the code up and this reduced the time taken to make it as wizpic dose all the PIC set-up and even has modules that can be placed into your code (things like LCD drivers, I/O ports and so on). This project assumes that you have a understanding of building robots and making electronic circuits but just need a helping hand to get you started with programming the PIC.

The sensors can be made out of nearly any switch you can get hold of or you could make your own using piano wire. There is three sensors and a start up and dance switch. The sensors will detect obstacles to the left , right and in front of the robot, while the "startup" switch will tell the robot to start moving when you have applied the power and pressed the switch I did this so it doesn't whizz off before you get time to properly position it. The dance switch is just a bit off a joke it makes the robot go through a number of moves and then returns to the main program. The switches should be arranged in the same fashion as can be seen in the photos.

All switches should be momentary and NOT toggle.

The PIC micro running speed is 4 MHz. I used a 4 MHz ceramic resonator to set the speed.


You will need to have two motors with gear boxes and two H-bridges (For a basic H-bridge circuit click here). The motors and gear boxes I used came from servos I took all the electronics out and just left the motor and gear box in place. Connect the motors to the H-bridges and make sure they work. Connect all the stuff (motors, H-bridges, sensors and chassis etc. ) Then use the chart down the page to connect it all to the PIC. Note that this program is not limited by the size of the robot however should you chose to make a big version of the robot the turning loop delays will need to be increased to make up for the more time the robot takes to turn.

For the PIC Micro Robot you will require the following parts:

  • A PIC Micro programmer (capable of programming the 16F84 PIC) Or buy a programmed chip of me.
  • Two geared motors (I used servos and took the electronics out)
  • Two H-bridges (for driving the motors)
  • One chassis (of your own taste!)
  • Three sensors (switches will do)
  • Two switches
  • One LED
  • A PIC 16F84 Or buy a programmed chip of me.
  • A PIC main board (for the PIC electronics)
  • 4 MHz ceramic resonator
  • And finely a human brain with body!

    The PIC code is available here free of charge to any one that wants to use it so long as you DON'T copy and sell it. And I do not take any responsibility for the software (PIC code) so if it blows up your PIC and burns down your house don't blame me.

    There is a lot of files in the win zip file and you will need them all. Ideally you should use wizpic (click here to get it) to open the files and program it into your PIC but if you go threw the files you will find one that your pic programmer software will like (I use the "X1_MPL.HEX" file)

    Download the PIC code (about 60kb win zip file.)

    Download KTX1-REV1.2D (60kb win zip file.) NEW

    At the moment the code is on REV 1.1D but I'm always fiddling and adding more so keep checking this web site for updates.

    Above is the layout of the PIC Micro and it's connection to the sensors, motors and start up LED. The following is a chart to show you what ports get connected to what hardware.

    label on photo
    were it goes (hardware connections)
    front right hand sensor (switch) on robot
    front left hand sensor (switch) on robot
    switch (momentary) tells robot to move
    right hand motor going forward (connect to H-bridge)
    right hand motor going backwards (connect to H-bridge)
    left hand motor going forwards (connect to H-bridge)
    left hand motor going backwards (connect to H-bridge)
    LED (turns on when PIC starts then goes off)

    Make sure that you connect the H-bridge correctly other wise you will short out the H-bridge.


    For version KTX1-REV1.1D

    dance = switch (momentary) makes robot dance
    frontsensor = front sensor (switch) on robot


    Code reading

    The code is clearly marked all the way through so you can change bits and bobs with out the hassle of finding out what every thing dose (check bellow for a slice of the code).

    bcf mot2bkPort,mot2bkBit ;turns backward motor2 off
    bcf mot1bkPort,mot1bkBit ;turns backward motor1 off
    movlw 255 ; delay loop
    call WaitWm ;delay loop
    bsf mot1bkPort,mot1bkBit ;turns motor1 on backward
    bsf motor2Port,motor2Bit ;turns motor2 on forward

    PIC code = what it does
    bcf mot2bkPort,mot2bkBit = turns that port off (0)
    bsf motor2Port,motor2Bit = turns that port on (1)

    bcf means turn port off then the info after that specifies were the port is.

    bsf means turn port on then the info after that specifies were the port is.

As you can see from the photos of KTX1 (the robot) I have only done a mock up of the robot just so I could test the PIC Micro code it's always a good idea to do that so you don't waste time and money. I have plans to make a big version of KTX1 that will probably use the PIC 16F877 and will have serial communication on board so it can talk to a computer and the code for that will also be free for you to download. You can also see that on the PIC Micro H-bridge out puts I have put LED's on as well this also helps to check, so you can see what ports are on and what are off. If you have made changes to the motor control code you should disconnect the H-bridges and test it on the LED's just to be sure.

Oh and if you do use the PIC assembly code I would love to here what your comments and thoughts are about it (E-mail me using the address bellow).

Ready programmed PIC chip with the latest version of the KTX1 code available for 7.00 This price is for UK residence only and excludes postage and packing (charged at £2.95). If your outside the UK and want a programmed chip let me know so we can find out how much it costs to send the chip abroad and if it's worth doing. Please see the "Robotics Parts Shop" for more details and how to order.

If your interested in building a PIC controlled Robot please look at "ARM RAM" as it's a better and is an easier Robot to build (Also cheaper).








Web pages built and by A R Martin E-mail at:


Home-page Robots Tutorials Links E-mail Circuits Events BEAM PIC Microchip Robotics Shop Computers FMM-RobotWars Sponsors Suggested reading Ebay Listings Serial Speed Controllers MicroMouse Walkers Driller-Killer Laptops Excaliber Robot Retox Drill Robot Robot motors Robot Builder Google Robux Project gorobotics Robot Cafe Robotics Solar Navigator PIC Axe Tech Supplies MUTR GSM Control Home Automation RC tracker Qtronics Design - Electronics & Firmware Design Artist R C Martin

HP 7210 Right Cartridge Error