Friday, 24 February 2012

WEEK 4


Programming for the system to function as we expected.
The programming shown as follow:

#include <16F877A.H>
#fuses NOWDT,HS, NOPUT,NOPROTECT
#use delay (clock=20000000)

#define PUSH_BUTTON PIN_D0
#define PUSH_BUTTON1 PIN_D1
#define PUSH_BUTTON2 PIN_D2

void main ()
{
   int x=1,y=1,z=1;
   int count=0;
   while(TRUE)
   {
      output_a(count);
      x=input(PIN_D0);
      y=input(PIN_D1);
      z=input(PIN_D2);
   
      if(x==0)
      {
         output_b(0b00011111);

         if(y==0)
        {
            count++;
            delay_ms(300);
            output_a(count);
                     
            output_b(0b00011111);
            output_c(0b00000001);
            delay_ms(1000);
         
            output_c(0b00000011);
            delay_ms(1000);
         
            output_c(0b00000111);
            delay_ms(1000);
         
            output_c(0b00001111);
            delay_ms(1000);
         
            output_c(0b00011111);
            delay_ms(1000);
        }
         
       
       
            else if(z==0)
            {
               count--;
               delay_ms(300);
               output_a(count);
             
                   
               output_b(0b00011111);
               output_c(0b00011111);
               delay_ms(1000);
             
               output_c(0b00011110);
               delay_ms(1000);
             
               output_c(0b00011100);
               delay_ms(1000);
             
               output_c(0b00011000);
               delay_ms(1000);
         
               output_c(0b00010000);
               delay_ms(1000);
             
               output_c(0b00000000);
               delay_ms(1000);
            }
         }
   
   
      else
         output_b(0b00000000);
   }
}
By using PicC software for programming



No comments:

Post a Comment