Blink LED (Serial port) RTS pin 12 Years Ago NicAx64 0 Tallied Votes 486 Views Share Circuit,Circuit Diagram Video:Video c windows-api 0 0 Share Copy to Clipboard#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); } 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!