Circuit,
Circuit Diagram
Video:
Video
#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);
}
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.