Thursday, October 14, 2010

Week 12 Programming for The Mobile Robot First Circuit

This week my partner had design a first sample for mobile robot so had to create a programming for the circuit to show a basic movement of the robot such move left, right, forward, reverse and stop.
Figure below show the circuit design:


And this is the programming for the circuit:
#include <16f84a.h>
#fuses   HS,NOWDT,PUT
#use delay(clock=20000000)

void main()
{
   while(TRUE)
   {
      if(!input(pin_a0))
      {
         output_b(0x68);
         delay_ms(3000);
         output_b(0x6A);
      }
      else if(!input(pin_a1))
      {
         output_b(0x62);
         delay_ms(3000);
         output_b(0x6A);
      }
      else if(!input(pin_a2))
      {
         output_b(0x6A);
      }
      else if(!input(pin_a3))
      {
         output_b(0x74);
      }
      else if(!input(pin_a4))
      {
         output_b(0x00);
      }
   }
}

In this programming, i had use if-else function for the selection of input switch and the output controlled by sending a data to the whole port.

2 comments:

  1. what the function for the pin11 and 12?? can you explain more clearly about this circuit??? tq..

    ReplyDelete