Menu DaniWeb
Log In Sign Up
  • Read
  • Contribute
  • Meet
  1. Home
  2. Programming Forum
  3. Software Development Forum
  4. Code Snippet Repository
  5. Reusable Code Snippet

Blink LED (Serial port) RTS pin

12 Years Ago NicAx64 0 Tallied Votes 489 Views Share

Circuit,
Circuit Diagram

Video:
Video

c windows-api
#ifndef __UNICODE__
#define __UNICODE__
#endif
#ifndef UNICODE
#define UNICODE
#endif
#ifndef _UNICODE
#define _UNICODE
#endif
#include <windows.h>
#include <stdio.h>

TCHAR * serial_port = L"COM2";

void BlinkLED(HANDLE hfile)
{
  while(TRUE){
    EscapeCommFunction(hfile,SETRTS);
    sleep(1);
    EscapeCommFunction(hfile,CLRRTS);
    sleep(1);
  }
}

int main(int argc,char** argv)
{
  HANDLE hfile = CreateFile(serial_port ,GENERIC_READ |GENERIC_WRITE ,\
                            0,
							0,
							OPEN_EXISTING,
							FILE_ATTRIBUTE_NORMAL,
							0);
	if (hfile==INVALID_HANDLE_VALUE)
	{
	  MessageBox(NULL,TEXT("Serial Port Does not Exist!"),TEXT("LED ON"),NULL);
	  exit(0);
	 }
	 
	 BlinkLED(hfile);
	 
	 CloseHandle(hfile);
}
About the Author
Member Avatar for NicAx64
NicAx64 76 Posting Pro

well I love technology and want to implement new and make the human life easy.ppl say I am kind thanks and I love to hear that.In programming I am not a expert , but love expertise advice , I want to listen and debug and read than code.My #1 programming…

Be the first to reply
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.

Sign Up — It's Free!
Related Topics
  • Member Avatar Reading multiple files in win32 c++ 3
  • Member Avatar How to check serial (com) port is available or not in j2me? 1
  • Member Avatar Need help storing data from file to array 7
  • Member Avatar Reading text from textbox and passing to serialPort 1
  • Member Avatar With XSLT, how can I add a node inside of a for loop? Example for the Q... 3
  • Member Avatar GDI+ Double Buffering 1
  • Member Avatar runtime error#58 15
  • Member Avatar Sending Image data over serial Port 3
  • Member Avatar Help me make this program shorter.. 7
  • Member Avatar Multiple Serial Port Signal Handler 2
  • Member Avatar Mobile Game Topic 2
  • Member Avatar serial communication using c programming in linux not working 4
  • Member Avatar Enum registry keys problem 4
  • Member Avatar C++(pointers) problem reads input strings from a file and that replaces all the vowel 1
  • Member Avatar Why is there so much assembly? 6
  • Member Avatar C program to replace all the letters of a string with all 26 alphabets..... 8
  • Member Avatar Read in 2-column CSV, output many files based on field 1
  • Member Avatar C programming in IOS? 2
  • Member Avatar C++ Programming 6
  • Member Avatar C++ program to find sum of marks entered by 30 students 2
Not what you need?

Reach out to all the awesome people in our software development community by starting your own topic. We equally welcome both specific questions as well as open-ended discussions.

Start New Topic
Topics Feed
Reply to this Topic
Edit Preview

Share Post

Insert Code Block

  • Forums
  • Forum Index
  • Hardware/Software
    • Recommended Topics
  • Programming
    • Recommended Topics
  • Digital Media
    • Recommended Topics
  • Community Center
    • Recommended Topics
  • Latest Content
  • Newest Topics
  • Latest Topics
  • Latest Posts
  • Latest Comments
  • Top Tags
  • Topics Feed
  • Social
  • Top Members
  • Meet People
  • Community Functions
  • DaniWeb Premium
  • Newsletter Archive
  • Markdown Syntax
  • Community Rules
  • Developer APIs
  • Connect API
  • Forum API Docs
  • Tools
  • SEO Backlink Checker
  • Legal
  • Terms of Service
  • Privacy Policy
  • FAQ
  • About Us
  • Advertise
  • Contact Us
© 2025 DaniWeb® LLC