Hi I write a code. But it didnt work. Led is burning and burning out not with range.
Where is the problem
#include "msp430g2452.h"
#define tr BIT0
#define ec BIT1
#define led BIT6
int range=0;
void main( void )
{
WDTCTL = WDTPW + WDTHOLD; //watchdog stop
DCOCTL=CALDCO_1MHZ; //frequency setup
BCSCTL1=CALBC1_1MHZ;
P1DIR = tr+led;
P1OUT=0x00; //all are zero
for(;
{
P1OUT^=tr; //Trigger is on for 10 us
__delay_cycles(10);
P1OUT^=tr;
if(P1IN&ec)
{
range++; //when echo coming ran