2012年11月6日 星期二

DE2 GPIO expansion Relay + LED實驗 (2)

DE2 GPIO expansion Relay + LED實驗 (2)

透過NPN 2N2222A 驅動5V relay ON/OFF LED 

GPIO_0 ,GPIO_1 o/p僅3.3V DC









module EX_2 (GPIO_0 ,GPIO_1 , SW, LEDR, LEDG , CLOCK_27 ,KEY );

inout  [35:0]GPIO_0;
inout  [35:0]GPIO_1;
input  [17:0] SW; // toggle switches
input  [7:0] KEY;     // Push bottom
input  CLOCK_27; //Clock 27MHz , 50Mhz

output [17:0] LEDR; // red  LEDS   
  output [7:0] LEDG; // green LEDs
  
    reg [35:0]GPIO_0,GPIO_1;
    
    reg [7:0] LEDG;
   
 //  -- GPIO (expansion headers)
 
always @(SW[0])
begin  
if (SW[0]==1'b1)
begin
GPIO_1 <= 36'bZ ;
GPIO_0[12:8] <= 4'b1111;
end

else
GPIO_0[12:8] <= 4'b0000;

    end  
    
  
    
   always @(GPIO_0[12:8])
   begin
if (GPIO_0[8]==1'b1)
begin

LEDG[7:0] <= 8'b00001010;
end

else
LEDG[7:0] <= 8'b11110101;
   end  
    
       
endmodule

沒有留言:

張貼留言

MQTT Explorer 與 Node-Red 介面的實驗

 MQTT Explorer 與 Node-Red 介面的實驗 MQTT EXplorer 與 Node-Red介面的設定 (1) 設定  MQTT EXplorer Client    (2)        Node-Red LED ON  --> MQTT Explor...