Moxa DA-682A-C7-W7E [51/53] Led controls

Moxa DA-682A-C7-W7E [51/53] Led controls
DA-682A Win7 Software Sample Code for DA-682A Customization
B-2
LED Controls
Below we reproduce the LED control code. This is a simple code that users may freely modify this code to suit
their needs.
/* Copyright (C) MOXA Inc. All rights reserved.
This software is distributed under the terms of the
MOXA License. See the file COPYING-MOXA for details.
*/
#include "stdafx.h"
#include <windows.h>
#include "..\\Include\\mxdev.h"
#define LED_PORT_NUMBER 8
int _tmain(intargc, _TCHAR* argv[])
{
HANDLE hLedDev;
intport_no;
int data;
intnLED = 0;
intnRet = 0;
int port = 0;
int mode = 0;
int n = 0;
TCHAR sin;
TCHAR smode;
_tprintf(_T("LED Test Program\r\n"));
_tprintf(_T("\t (0) Exit Program\r\n"));
_tprintf(_T("\t (1) Display LED\r\n"));
_tprintf(_T("\t (2) Set LED value\r\n"));
sin = _gettchar();
n = _tstoi(&sin);
do
{
switch (n)
{
// if char == '1', display the LED output status
case 1:
// Open device
hLedDev = mxgpio_open();
for (inti = 0; i< LED_PORT_NUMBER; i++)
{
// Get digital input
port_no = i;
nLED = mxgpio_get_data( hLedDev, port_no);
_tprintf(_T("LED[%d] = %d\r\n"), port_no, nLED);
}

Содержание

Похожие устройства