DATA<=X"52"; --R
when 193=>
DB<=DATA(7 downto 4);
when 194=>LCD_E<='1';
when 195=>LCD_E<='0';
when 196=>DB<=DATA(3 downto 0);
when 197=>LCD_E<='1';
when 198=>LCD_E<='0';
architecture Behavioral of debounce is
signal counter : integer range 0 to 15000000;
signal buton_b : std_logic;
signal buton_g : std_logic;
signal cnt : integer range 0 to 8;
signal ledg : std_logic_vector(7 downto 0);
begin
led <= ledg;
process(clk) -- Debounce
begin
if(clk'event and clk='1') then
if(buton_b <= '1') then
counter<=counter+1;
buton_g<='0';
elsif(buton='1') then
buton_b<='1';
end if;
if(counter=15000000) then --300ms
counter<=0;
buton_b<='0';
if(buton='1') then
buton_g<='1';
end if;
end if;
end if;
end process;
process(clk) --Cnt
begin
if(clk'event and clk='1') then
if(buton_g='1') then
cnt<=cntc+1;
if(cnt=8) then
cnt<=0;
end if;
end if;
end if;
end process;
process(cnt)
begin
case cnt is
when 0 => ledg <= "00000000";
when 1 => ledg <= "00000001";
when 2 => ledg <= "00000010";
when 3 => ledg <= "00000100";
when 4 => ledg <= "00001000";
when 5 => ledg <= "00010000";
when 6 => ledg <= "00100000";
when 7 => ledg <= "01000000";
when others => ledg <= "10000000";
end case;
end process;
DATA<=(conv_std_logic_vector((cnt),8));
int i;
......
...
lcd_write_byte(i+48);
process(cnt)
begin
case cnt is
when 0 => ledg <= "00000000";
when 1 => ledg <= "00000001";
when 2 => ledg <= "00000010";
when 3 => ledg <= "00000100";
when 4 => ledg <= "00001000";
when 5 => ledg <= "00010000";
when 6 => ledg <= "00100000";
when 7 => ledg <= "01000000";
when others => ledg <= "10000000";
end case;
end process;
DATA<=(conv_std_logic_vector((cnt+48),8));
cnt=cnt+48;
DATA<=(conv_std_logic_vector((cnt),8));
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity tplcdvebuton is
port (
buton : in std_logic;
led : out std_logic_vector(7 downto 0);
clk : in std_logic;
DB : out STD_LOGIC_VECTOR (7 downto 4);
LCD_E :out STD_LOGIC;
LCD_RS :out STD_LOGIC;
LCD_RW :out STD_LOGIC
);
end tplcdvebuton;
architecture Behavioral of tplcdvebuton is
--------------- Signals for Button and Debounce ----------------
signal counter : integer range 0 to 15000000;
signal buton_b : std_logic;
signal buton_g : std_logic;
signal cnt : integer range 0 to 8;
signal ledg : std_logic_vector(7 downto 0);
-----------------------------------------------------------------------------
--------------- Signals for Lcd ------------------------------
Signal StopTimer:std_logic;
Signal DATA : STD_LOGIC_VECTOR (7 downto 0);
-----------------------------------------------------------------------------
begin
led <= ledg;
process(clk) -- Debounce
begin
if(clk'event and clk='1') then
if(buton_b <= '1') then
counter<=counter+1;
buton_g<='0';
elsif(buton='1') then
buton_b<='1';
end if;
if(counter=15000000) then --300ms
counter<=0;
buton_b<='0';
if(buton='1') then
buton_g<='1';
end if;
end if;
end if;
end process;
process(clk) --Cnt
begin
if(clk'event and clk='1') then
if(buton_g='1') then
cnt<=cnt+1;
if(cnt=8) then
cnt<=0;
end if;
end if;
end if;
end process;
process(cnt) -- Checking the value of cnt with using LEDs
begin
case cnt is
when 0 => ledg <= "00000000";
when 1 => ledg <= "00000001";
when 2 => ledg <= "00000010";
when 3 => ledg <= "00000100";
when 4 => ledg <= "00001000";
when 5 => ledg <= "00010000";
when 6 => ledg <= "00100000";
when 7 => ledg <= "01000000";
when others => ledg <= "10000000";
end case;
end process;
------------------------------------- LCD ------------------------------------
process (clk)
variable say1:integer;
variable say2:integer;
begin
if (clk'EVENT and clk='1') then
if (StopTimer='0') then
say1:=say1+1;
end if;
if (say1>50000) then --1 KHZ
say1:=0;
say2:=say2+1;
case say2 is
when 90=>
LCD_RW<='0';
LCD_RS<='0'; --CMD
DB<="0011";
when 99=>LCD_E<='1';
when 100=>LCD_E<='0';
when 115=>LCD_E<='1';
when 116=>LCD_E<='0';
when 121=>LCD_E<='1';
when 122=>LCD_E<='0';
when 127=>DB<="0010";
when 128=>LCD_E<='1';
when 129=>LCD_E<='0';
when 149=>DATA<=X"28";
when 150=>DB<=DATA(7 downto 4);
when 151=>LCD_E<='1';
when 152=>LCD_E<='0';
when 153=>DB<=DATA(3 downto 0);
when 154=>LCD_E<='1';
when 155=>LCD_E<='0';
DATA<=X"08";
when 156=>DB<=DATA(7 downto 4);
when 157=>LCD_E<='1';
when 158=>LCD_E<='0';
when 159=>DB<=DATA(3 downto 0);
when 160=>LCD_E<='1';
when 161=>LCD_E<='0';
DATA<=X"01";
when 162=>
DB<=DATA(7 downto 4);
when 163=>LCD_E<='1';
when 164=>LCD_E<='0';
when 165=>DB<=DATA(3 downto 0);
when 166=>LCD_E<='1';
when 167=>LCD_E<='0';
DATA<=X"06";
when 168=>
DB<=DATA(7 downto 4);
when 169=>LCD_E<='1';
when 170=>LCD_E<='0';
when 171=>DB<=DATA(3 downto 0);
when 172=>LCD_E<='1';
when 173=>LCD_E<='0';
DATA<=X"0C";
when 174=>
DB<=DATA(7 downto 4);
when 175=>LCD_E<='1';
when 176=>LCD_E<='0';
when 177=>DB<=DATA(3 downto 0);
when 178=>LCD_E<='1';
when 179=>LCD_E<='0';
when 180=>LCD_RS<='1'; --Chr
DATA<=X"43"; -- C
when 181=>
DB<=DATA(7 downto 4);
when 182=>LCD_E<='1';
when 183=>LCD_E<='0';
when 184=>DB<=DATA(3 downto 0);
when 185=>LCD_E<='1';
when 186=>LCD_E<='0';
DATA<=X"4E"; -- N
when 187=>
DB<=DATA(7 downto 4);
when 188=>LCD_E<='1';
when 189=>LCD_E<='0';
when 190=>DB<=DATA(3 downto 0);
when 191=>LCD_E<='1';
when 192=>LCD_E<='0';
DATA<=X"54"; -- T
when 193=>
DB<=DATA(7 downto 4);
when 194=>LCD_E<='1';
when 195=>LCD_E<='0';
when 196=>DB<=DATA(3 downto 0);
when 197=>LCD_E<='1';
when 198=>LCD_E<='0';
DATA<=X"3D"; -- =
when 199=>
DB<=DATA(7 downto 4);
when 200=>LCD_E<='1';
when 201=>LCD_E<='0';
when 202=>DB<=DATA(3 downto 0);
when 203=>LCD_E<='1';
when 204=>LCD_E<='0';
DATA<=(conv_std_logic_vector((cnt+48),8));
when 205=>
DB<=DATA(7 downto 4);
when 206=>LCD_E<='1';
when 207=>LCD_E<='0';
when 208=>DB<=DATA(3 downto 0);
when 209=>LCD_E<='1';
when 210=>LCD_E<='0';
when 3000=> --StopTimer <='1';
when others=>
end case;
end if;
end if;
end process;
end Behavioral;
signal cnt : integer range 0 to 8 :=3;
begin
if (clk'EVENT and clk='1') then
if (StopTimer='0') then
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?