Question
I am using a MSP430F5529LaunchPad - Code Composer Studio 7.4 and I am trying to implement the following task: Design and implement a car belt
I am using a MSP430F5529LaunchPad - Code Composer Studio 7.4 and I am trying to implement the following task:
Design and implement a car belt controller. The controller will illuminate a red LED on the vehicle's car seat diagram if someone is sitting in a car seat and is not fastened within a fixed amount of time. If the passenger is fastened within the above space, the controller will turn on a green LED respectively. This system has three inputs and two outputs. The inputs are a Push Button Sensor (P1.1) to know when a person is sitting, a Push Button (P2.1) that recognizes whether the belt is tied or not by the passenger and a timer notifying that the required time has elapsed. The controller is idle when there is no one in the seat. When someone sits, the controller turns on the timer. If the stopwatch stops before the seat belt is tightened, the red LED lights up. If the seat belt is fastened in time, the green LED lights up and the controller enters a surveillance mode. During the surveillance it is checked whether the passenger continues to have the belt tied. When the passenger leaves the seat, the controller returns to idle status.
So far, I wrote the following program:
#include
#include
volatile unsigned short SEAT =0;
volatile unsigned short BELT =0;
void main()
{
GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P1,GPIO_PIN1);//ENABLE RESISTOR P1.1
SEAT=GPIO_getInputPinValue(GPIO_PORT_P1,GPIO_PIN1);//SET PIN VALUE
GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P2,GPIO_PIN1);//ENABLE RESISTOR P2.1
BELT=GPIO_getInputPinValue(GPIO_PORT_P2,GPIO_PIN1);//SET PIN VALUE
//LED INITIALIZATION
GPIO_setAsOutputPin(GPIO_PORT_P1,GPIO_PIN0);
GPIO_setAsOutputPin(GPIO_PORT_P4,GPIO_PIN7);
GPIO_setOutputLowOnPin(GPIO_PORT_P1,GPIO_PIN0);
GPIO_setOutputLowOnPin(GPIO_PORT_P4,GPIO_PIN7);
while (1){
if((BELT== GPIO_INPUT_PIN_LOW)&&(SEAT==GPIO_INPUT_PIN_LOW))
{
GPIO_setOutputHighOnPin(GPIO_PORT_P4,GPIO_PIN7 );
}
if(SEAT==GPIO_INPUT_PIN_LOW){
GPIO_setOutputHighOnPin(GPIO_PORT_P1,GPIO_PIN0);
}
}
}
I think its ok, but I dont know how to implement the timer that lights the RED LED to notify that someone is sitting in a car seat and is not fastened within a fixed amount of time (for example after 10secs).
I would really appreciate if someone could add to the above program the necessary code.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started