I have a problem. BIG one. I have a LED connected to pin 3 and 5 at serial port (rs232). Here is the code I make, who blink that led at an interval from a timer. private SerialPort o_port = new SerialPort( " COM3" , 9600 , Parity.Odd, 8 , StopBits.One); private void button1_Click( object sender, EventArgs e) { timer1.Enabled = true ; } ...
You could write a timer, then write a loop that sends the data over and over, and turn it off when the timer fires, if you send the data on another thread. That's assuming that the data gets sent once, that it's not a switch you turn on or off. That's how it worked when I worked with the serial port, you'd turn the pin on, set a timer, then turn it off again.
well, when I integrate a while loop, my pc crash. I really dont know how to do it...I dont have any clue. Please write me a code to have a inspiration on how to do it. Im a bit new to this . thanks.
merlinq12 wrote: well, when I integrate a while loop, my pc crash. How does it crash ? What happens ? What's the code ? merlinq12 wrote: Please write me a code to have a inspiration on how to do it. Im a bit new to this Smile. It's years since I did it, but have you tried just setting it once ? Does that turn the LED on, or make it flash on and off ?
private void timer1_Tick( object sender, EventArgs e) { // this code crash my pc int number = 1 ; while (number == 1 ) { o_port.WriteLine( " xxx" ); } } The original code make the led flash/ ON and OFF. I dont know how to turn the pin ON !!!!
Hi, You have connected the LED between transmit data (TD) and ground (SG). Is is your intention to show when data is being transmitted or do you just want to turn an LED on and off? If it's the latter then it would be better to connect the LED to one of the control lines, e.g. data terminal ready (DTR) or request to send (RTS), and ground. These lines can be toggled or or off via the ...
Hi, you're taking a bad approach here. The data lines (TD and RD) carry a serial data stream, which consists of start bits, data bits, parity bit, and stop bits; and by definition are not constant. What you want can be achieved by using one of the control lines (that would be DTR or RTS, and it requires a hardware change to your current LED connection). You can use SerialPort class, open the ...
ohooohooo... Its Christmas time Thank you very much for this very good advice, guys. Oau. I use a usb to serial converter, and a bright LED , so I don't mind about the U/Led. I wonder ... hmmm..I can run a stepper motor with this? Actually at this is serve the experiment with the led. Of course I will use a demultiplexor, a uln2004, and some bunch of wires. If you know a better way (...
merlinq12 wrote: I don't mind about the U/Led. I don't know what you mean here, if you want to forgo the resistor chances are you will ruin your serial port, which will cost you more than thousands of resistors. merlinq12 wrote: .I can run a stepper motor with this? with the proper H bridge in place you can control motor steps, yes. However: - there is bound to be some unpredictable ...
Luc Pattyn thanks for your prompt response ... very nice and clean explanations (not very detailed but enough & strait forward). Thanks man. And I Dont abuse anything, I was beginning the discussion from SerialPort class, and one thing to another I was jumping to other interesting stuff. I see that I am away a bit from my original post, so I will no longer continue . I understand. hmmm...
though ... I must put for others the !Finished! customized code : // if you are to set different time intervals? // say 100ms to ON state and 400ms to OFF state? // Here is the answer! ...and the final finished code! // all other usings + using System.IO.Ports; private SerialPort port = new SerialPort( " COM3" , 9600 , Parity.Odd, 8 , StopBits.One); public Form1() { InitializeComponent(); port.Open(); } private void...
merlinq12 wrote: I don't mind about the U/Led. I don't know what you mean here, if you want to forgo the resistor chances are you will ruin your serial port, which will cost you more than thousands of resistors. merlinq12 wrote: .I can run a stepper motor with this? with the proper H bridge in place you can control motor steps, yes. However: - there is bound to be some unpredictable delay between setting a control line in software,...
Hi, You have connected the LED between transmit data (TD) and ground (SG). Is is your intention to show when data is being transmitted or do you just want to turn an LED on and off? If it's the latter then it would be better to connect the LED to one of the control lines, e.g. data terminal ready (DTR) or request to send (RTS), and ground. These lines can be toggled or or off via the SerialPort class. The timer tick code would be e.g....
Related threads on "CodeProject: Discussion Boards. Free source code and programming help":
Thread profile page for "led to rs232 [modified]" on http://www.codeproject.com.
This report page is a snippet summary view from a single thread "led to rs232 [modified]", located on the Message Board at http://www.codeproject.com.
This thread profile page shows the thread statistics for: Total Authors, Total Thread Posts, and Thread Activity