Team5

Members:Ann Viitala, Olga Danilova, He Yini, Chen Hao

Our primary idea of the code is below:

#include <REG51.H>
#include "door.h"
 
////////////////////////////////////////////////////////////////////
//    Task:         Simulate Garage Door Controlling System        //
//             Subject:                     Embedded C             //
//             Author:                     Group#5 :              //
//            Olga Danilova, Ann Viitala, He Yini, Chen Hao       //
//////////////////////////////////////////////////////////////////// 
 
void main(void)
{
    P1           = 0xFF;                 // put port P1 into input mode                  
    Button         = UP;                 // P3_0 button, initially up 
    Motor          = UP;                 // initially motor is off 
    Direction         = UP;                 
    Door           = DOWN;              // we start from state Door_DOWN
 
while(1) {
    if( Button == DOWN && Door == DOWN)    
    {
        int opening = 1000; 
 
         // we assume that after 1000 counts door is fully open
 
            Motor = DOWN;    
     while(opening)
     {
             opening--;
            Direction = UP;        
     }
     Door   = UP;
     Button = UP;
    }
    else if (Button == DOWN && Door == UP)
    {    
int closing = 1000;    
 
// we assume that after 1000 counts door   is fully closed
 
              Motor = DOWN;    
     while (closing)
     {
             closing--;
            Direction = DOWN;
     }
     Door    = DOWN;
     Button = UP;
    }
    else
    {
     Motor = UP;
    }
 }
} // Door.c
 
#ifndef door_H_
#define door_H_
 
// assigning bit values for input devices
sbit    Door         = P1^0;    
sbit    Motor        = P1^1;    
sbit    Direction = P1^2;    
sbit    Sensor    = P1^3;        
// assigning bit values for the output 
sbit    Button       = P3^0;   // Control    button
// On is set to a 1 value, and 0 stands for off
UP      =      0;
DOWN      =      1;
 
#endif
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License