Toll-Free Customer Support 24/7

IR Obstacle Sensor Interfacing with MSP430

 

 

/*   create file  named called   ir.c and paste below given program

/*

 * Project name:

    IR-SENSOR

 * Copyright

     (c) Researchdesignlab.com

 * Test configuration:

     MCU:             MSP430G2553

     Dev.Board:       TI LAUNCHPAD

     Oscillator:      16 MHz

     Software:        CCS STUDIO V.5

 

*/

 

#include "msp430g2533.h"

#include"lcd.h"

 

int main(void)

{

WDTCTL = WDTPW + WDTHOLD;            //Stop WDT

BCSCTL1 = CALBC1_8MHZ;                     //Set DCO to 8Mhz

DCOCTL = CALDCO_8MHZ;

P2DIR &= ~BIT0;   // IR SENSOR IS CONNECTED TO PORT2 OF BIT0

InitializeLcm();  //INITIALIZE LCD

__delay_cycles(1000000);

//ClearLcmScreen(); //CLEAR LCD

//__delay_cycles(1000000);

while(1)

{

if(P2IN == 0x01) //  IF IR IS HIGH

{

ClearLcmScreen();

PrintStr("IR HIGH"); //WRITE TEXT IR HIGH

__delay_cycles(1000000);//GIVE SOME DELAY

}

else

{

ClearLcmScreen();

PrintStr("IR LOW");  //WRITE TEXT IR LOW

__delay_cycles(1000000); // GIVE SOME DELAY

}

}

}

 

 

// end of ir.c file

//………………………………………………………………………………………………………………………………………………………

 

/*   create file  named called   lcd.c  and paste below given program

/*

 * Project name:

    IR-SENSOR

 * Copyright

     (c) Researchdesignlab.com

 * Test configuration:

     MCU:             MSP430G2553

     Dev.Board:       TI LAUNCHPAD

     Oscillator:      16 MHz

     Software:        CCS STUDIO V.5

 

*/

 

#include "msp430g2533.h"

#include"lcd.h"

 

int main(void)

{

WDTCTL = WDTPW + WDTHOLD;            //Stop WDT

BCSCTL1 = CALBC1_8MHZ;                     //Set DCO to 8Mhz

DCOCTL = CALDCO_8MHZ;

P2DIR &= ~BIT0;   // IR SENSOR IS CONNECTED TO PORT2 OF BIT0

InitializeLcm();  //INITIALIZE LCD

__delay_cycles(1000000);

 

//ClearLcmScreen(); //CLEAR LCD

//__delay_cycles(1000000);

while(1)

{

if(P2IN == 0x01) //  IF IR IS HIGH

{

ClearLcmScreen();

PrintStr("IR HIGH"); //WRITE TEXT IR HIGH

__delay_cycles(1000000);//GIVE SOME DELAY

}

else

{

ClearLcmScreen();

PrintStr("IR LOW");  //WRITE TEXT IR LOW

__delay_cycles(1000000); // GIVE SOME DELAY

}

}

}

 

// end of lcd.c file

//………………………………………………………………………………………………………………………………………………………

 

 

/*   create file  named called   lcd.h  and paste below given program

void PulseLcm();

void SendByte(char ByteToSend, int IsData);

void LcmSetCursorPosition(char Row, char Col);

void ClearLcmScreen();

void InitializeLcm(void);

void PrintStr(char *text);

// end of lcd.h file

//………………………………………………………………………………………………………………………………………………………

 

 

 

 

Back to top