📄 digital.c
字号:
/*
C language header file for sample programs for the ADT200/ADT600.
Science & Technology CO.,LTD.
Rm814-815,Shangda Plaza, Zhenhua,ShenZhen,GuangDong,P.R.C.
Tel: 86-755-3328081
Fax: 86-755-3343187
Zip: 518031
Board: SF94A-0102
Compiler: Turbo C (r) version 1.0, 2.0
Turbo C++ (r) version 1.0
Borland C++ (r) version 2.0, 3.0
Last update: Dec 24, 1994
DESCRIPTION
~~~~~~~~~~~
Sample program that demonstrates how to read and write the digital I/O
lines on the ADT200/ADT600. The program constantly displays the value
of the input lines in the center of the screen. You can enter a value
to be sent to the output lines. Jumpering the input lines to their
corresponding output lines will allow you to change the output lines and
view the changes at the same time.
NOTES
~~~~~
You must change the first line in the main function to reflect the
base address for your ADT200/600.
*/
#include <dos.h>
#include <stdio.h>
#include <conio.h>
#include <ADT600.h>
#include <ADT600.inc>
char ExitProgram, S[10], C;
unsigned char B;
void ProgramTitle(char S[])
{
gotoxy(1,1); clreol();
cprintf("ADT600 Sample Program");
gotoxy(80 - strlen(S), 1);
cprintf(S);
}
void main(void)
{
BaseAddress = 0x300;
clrscr();
ProgramTitle("Digital I/O");
gotoxy(1,24);
cprintf("Enter value to output (ESCAPE to exit): ");
gotoxy(31, 11); cprintf("IN: ");
ConfigureIOPorts(INPUT, INPUT, OUTPUT); /* Configure port 0, 1 for input,
port 2 for output */
ExitProgram = 0;
while (!ExitProgram)
{
gotoxy(35,11);
cprintf("%6d", ReadDigitalIO(0)); /* Read port 0 */
if (kbhit()) /* If key pressed get value to output */
{
C = getch();
if (C == 27) /* If ESCAPE then quit */
ExitProgram = 1;
else
{
if(C != 13)
{
gotoxy(42, 24);
putch(C);
S[0] = C;
gets(&S[1]);
sscanf(S, "%d", &B);
gotoxy(42, 24); clreol();
WriteDigitalIO(2, B); /* Write value to port 2 */
}
}
}
}
ConfigureIOPorts(INPUT, INPUT, INPUT); /* Port 0,1,2 all INPUT */
clrscr();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -