Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Controlling led with rs232

Status
Not open for further replies.

varunme

Advanced Member level 3
Advanced Member level 3
Joined
Aug 10, 2011
Messages
741
Helped
17
Reputation
36
Reaction score
17
Trophy points
1,318
Activity points
5,765
is there anyone knows links for controlling LEDs through serial port of PC ?
 

More specific...........
How many controlled led´s ?
Whatkind of control (on/off or brightness ) ?
 

3 LEDs
just on and off , using PIC microcontroller through RS232 from PC
 

from your previous thread, I assume you are using PIC16f87x and HI TECH C compiler .... If so,
then you can try this code:

(press key '1' to ON and '2' to OFF)


PHP:
#include<pic.h>
#define _XTAL_FREQ 20e6
__CONFIG(0x3F3A);


void usrt_init()
{
	TRISC6=0;
	TXSTA=0b00100100;	//CHECK THE DATA SHEET FOR TXSTA
	RCSTA=0b10010000;	//SEE THE DATA SHEET FOR RCSTA
	BRGH=0;			//  low baud rate 
	SPBRG=129;      //baud rate 2400
}

void interrupt_enable()
{
	GIE=1;
	PEIE=1;
	RCIE=1;
}

void interrupt UART()  //interrupt service routine
{	
if(RCREG == '1'){PORTD=0xff;}
else if(RCREG == '2'){PORTD = 0x00;}
}

void txd(char write_data)
{
	TXREG = write_data;
	while(!TRMT);
}


main()
{	
	TRISD=0;
	usrt_init();
	interrupt_enable();
	txd('H');	txd('E');	txd('L');	txd('L');	txd('O');
	while(1);	//WAITING FOR INTERRUPT (SEE RESULT ON PORT D)
	
}
 
Last edited:

    V

    Points: 2
    Helpful Answer Positive Rating

    V

    Points: 2
    Helpful Answer Positive Rating
Last edited:

Reason for that may be:
You may be connected the anode of LED to the Vcc.
For the reverse to happen, just use ground and RD0 to connect the LED...
 

yes ,
thanks for solving
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top