⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 traficlights.m

📁 daqaxis help for national instruments
💻 M
字号:
function ITraficLights
% A program to simulate Trafid Lights on the Bytronic LED's
% Set Switch3 0010 Switch4  1000
% Switch5 R  Switch 6 R Switch 7 R 
% Initialise parallel port
    base = 888;         %base address for LPT1;
	disp('Hello Bytronics')

    % send control word to set ports to correct
	% input and output status
    % Port A,B,CH,CL     1 in  0 out
	PortModeSet(base,1,0, 1, 1);

	% loop around this section of the programme until
	% positive number entered
    x=0;
	while x<1
        PPIOutVal(base,1);  % Green
        inport= PPIInpVal(base);
        green=bitand(inport,7) + 2;  % 1 + 2 + 4 = 7  Switched bits 0,1,2
        red=bitand(inport,56) / 8 + 2;  % 8 + 16 + 32 = 56 Switched bits  3,4,5
        Double=bitand(inport,64) / 64 + 1;  % 1 or 2
        delay(Double*green);
        PPIOutVal(base,2);  % Amber
        delay(1);
        PPIOutVal(base,4);  % Red
        delay(Double*red);
        PPIOutVal(base,6);  % Red & Amber
        inport= PPIInpVal(base);
        if bitand(inport,128) 
			disp('Bit 7 set high - exit routine activated');
            break;    
        end;
        delay(1);
    end;
	





⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -