loading
I was trying to put in a video but it didn't work for me, so here is a link to YouTube http://www.youtube.com/watch?v=9rS9nFG8xdI
 
This is a detailed instruction showing how to build a flashing L.E.D. using 555 Timer.
There is no knowledge of electronics required in order to complete this project.
All the parts needed are listed, priced and links to them are also included. 

There are two sets of pictures, the top shows the progression of the project and the bottom shows each step individually.

This is my first instructable and it is also an assignment so please leave comments.
Thank you.




Step 1: Parts List

Here you will find a list of all required parts, their pictures, prices and where to get them.
There is also an excel file attached.

1. Breadboard
2. 9v Battery
3. Battery clip
4. Jump Wires
5. 555 Timer
6. Capacitor 1μF
7. Resistor   1k Ohm            x 2 (brown, black, red)
8. Resistor    470k Ohm            (yellow, purple, yellow)
9. L.E.D.

Time needed to finish this project: 5 - 10 min.

All the above parts can be bought at http://radionics.rs-online.com/web/ next day delivery (Ireland).
rkpvtproject
<p><strong>PROJECT DEFINITION</strong></p><p>In<br>this Project we will develop a pong game and display it on a monitor. We will<br>carry the project on the FPGA and will send the video to the monitor via VGA interface.<br>Our video resolution will be 640x480 and eight colors.</p><p>We<br>will design two module in order to develop the Pong Game. First module called<br>SYNC MODULE will generate the HS (Horizontal Synchronization), VS(Vertical<br>Synchronization) and the control signals which is used by second module. Second<br>module called IMG GEN will generate the all necessary images is used in the<br>pong game. Below is the block diagram of the pong game module.</p><p>In<br>our project we will design the images by using only eight color. If you want to<br>increase the color , you should use the video DAC device like ADV7123</p><p>We<br>use Quartus II 11.1 version as compiler. We use Cyclone III FPGA Development<br>Kit in order to carry the project out. You can download the complete<br>project file from<a href="http://fpgacenter.com/examples/vga/vga.rar" rel="nofollow"> here.</a></p><p>Before<br>begin the project, let&rsquo;s take a quick look at the VGA protocol. </p><p>VGA(Video Graphics Array)</p><p>VGA is a<br>video display standard developed by IBM and introduced in 1987 in IBM. It is<br>widely supported by PC graphics hardware and monitors.</p><p>In VGA<br>standard The image is divided into array of small picture elements called<br>pixels. Every pixel contains a sample of the image. An image is displayed<br>on the screen by turning on and off individual pixels. The monitor continuously<br>scans through the entire screen and rapidly turning individual pixels on and<br>off</p><p>The<br>scanning starts from row 0, column 0 in the top left corner of the screen and<br>moves to the right until it reaches the last column shown in Figure 1. When the<br>scan reaches the end of a row, it retraces to the beginning of the next row.<br>When it reaches the last pixel in the bottom right corner of the screen , it<br>retraces back to the top-left corner where scanning began and repeats the scanning<br>process. The entire screen must be scanned(refresh) not less than 60 times per<br>second. This period is called the refresh rate.</p><p>There are<br>two type of signals in VGA</p><p>Control (Synchronization) Signal</p><p>There are<br>two Synchronization Signals used synchronization of the video in VGA called horizontal sync and<br>horizontal sync. These signals are digital signals.</p><p>Video</p><p>There are<br>three type video signals in VGA called Red(R), green(G) and blue(B). The three<br>color signals collectively referred to as the RGB signal control the color of a<br>pixel at a given location on the screen. They are analog signals with voltages<br>ranging from 0,7 to 1 V.</p><p>Three bit<br>VGA color combination</p><p>VGA Synchronization </p><p>Horizontal Synchronization</p><ul><li>Display:<br> Region where the pixels are<br> actually displayed on the screen.<li>Retrace:The time required for retracing<br> the cursor to the beginning of the next row when it reaches the end<br> of a row. This duration the video color must be set to black. <li>Front<br> porch(porch before retrace): The blanking interval before the sync pulse is known as<br> the front porch. Front porch forms the right border of the display region.<br> In this region The video signal should be disabled.<li>Back<br> Porch(porch after retrace):<br> The blanking interval after the sync pulse is known as the back porch.<br> Back porch forms the left border of the display region. In this region the<br> video signal should be disabled.</ul><p>Vertical Synchronization </p><ul><li>Display:<br> Region where the pixels are<br> actually displayed on the screen.<li>Retrace: The time required for<br> retracing the cursor to back to the top-left corner when it reaches the<br> last pixel in the bottom right corner of the screen. This duration the<br> video color must be set to black.<li>Front<br> porch(porch<br> before retrace): The blanking interval before the sync pulse is known as<br> the front porch. Front porch forms the right border of the display region.<br> In this region The video signal should be disabled.<li>Back<br> Porch(porch<br> after retrace) : the blanking interval after the sync pulse is known as<br> the back porch. Back porch forms the left border of the display region. In<br> this region the video signal should be disabled.</ul><p>VGA Timing</p><p>The<br>following table lists timing values for several popular resolutions.</p><p>After<br>taking a look at the VGA we can continue our project where we left off. </p><p>SYNC MODULE </p><p>First we<br>will design the sync module. This module will generate the horizontal sync and<br>vertical sync for VGA video. In addition, sync module also produce control<br>signals for the IMG GEN (image Generation) module. </p><p>SYNC<br>module has 3 inputs and 2 output signals. The following shows the definition of<br>these signals.</p><p>Input Signals</p><ul><li>start: is used to activate/deactivate<br> the module<li>clk: system clock<li>reset: is used to reset the module</ul><p>Output Signals</p><ul><li>H_S: Horizontal sync <li>V_S: Vertical sync<li>X_counter: output of a counter which<br> placed in the sync module. It counts from 0 to 639 (horizontal resolution<br> of the VGA video =640) <li>Y_counter: output of a counter which<br> placed in the sync module. It counts from 0 to 479(vertical resolution of<br> the VGA video ) <li>Video_on: is used to enable/disable the<br> video </ul><p>To meet<br>640x480 resolution we will define some constants in the program.</p><p>In our<br>project we will use 50 Mhz as a system clock. But according to the list given<br>previous part we need 25 Mhz clock signal in order to produce <br>640x480,@60Hz video. So we will 2 mod counter to generate 25 Mhz signal form<br>the 50 MHZ system clock. </p><p>We will<br>design two individual counters. First counter counts from 0 to 639 to meet<br>horizontal resolution, second counters counts from 0 to 479 to meet vertical<br>resolution. We will also define two signals called h_end and v_end <br>that indicates the end point of the counters. </p><p>We can<br>connect the VS and HS directly to the VGA connector. But as to RGB signals we<br>can not say the same thing. As we remembered the previous part, RGB are the<br>analog signals with ranging from 0 to 0,7 volt. So we should use 270 ohm<br>resistor between the RGB and VGA connector pins.(inner resistor of the monitor<br>is about 75 ohm and the output voltage of the FPGA 3.3 Volt.)</p><p>We connect<br>pin numbers 5 ,6,7,8 and 10 to ground. </p><p>Video_on<br>is 1 only if when video is displayed on the monitor. HS and Video_on signal<br>status will be as follows.</p><p>VS and<br>Video_on signal status will be as follows.</p><p>VHDL CODE</p><p>library<br>IEEE;<br><br>use IEEE.STD_LOGIC_1164.ALL;<br><br>use IEEE.STD_LOGIC_ARITH.ALL;<br><br>use IEEE.STD_LOGIC_UNSIGNED.ALL;</p><p>entity<br>sync_mod is<br><br> Port ( clk : in STD_LOGIC;<br><br> <br>reset : in STD_LOGIC;<br><br> <br>start : in STD_LOGIC;<br><br> <br>y_control : out STD_LOGIC_VECTOR (9 downto 0);<br><br> <br>x_control : out STD_LOGIC_VECTOR (9 downto 0);<br><br> <br>h_s : out STD_LOGIC;<br><br> <br>v_s : out STD_LOGIC;<br><br> <br>video_on : out STD_LOGIC);<br><br>end sync_mod;</p><p>architecture<br>Behavioral of sync_mod is<br><br> -- Video Parameters<br><br> constant HR:integer:=640;--Horizontal Resolution<br><br> constant HFP:integer:=16;--Horizontal Front Porch <br><br> constant HBP:integer:=48;--Horizontal Back Porch<br><br> constant HRet:integer:=96;--Horizontal retrace<br><br> constant VR:integer:=480;--Vertical Resolution<br><br> constant VFP:integer:=10;--Vertical Front Porch <br><br> constant VBP:integer:=33;--Vertical Back Porch<br><br> constant VRet:integer:=2;--Vertical Retrace<br><br> --sync counter<br><br> signal counter_h,counter_h_next: integer range 0 to 799;<br><br> signal counter_v,counter_v_next: integer range 0 to 524;<br><br> --mod 2 counter<br><br> signal counter_mod2,counter_mod2_next: std_logic:='0';<br><br> --State signals<br><br> signal h_end, v_end:std_logic:='0';<br><br> --Output Signals(buffer)<br><br> signal hs_buffer,hs_buffer_next:std_logic:='0';<br><br> signal vs_buffer,vs_buffer_next:std_logic:='0';<br><br> --pixel counter<br><br> signal x_counter, x_counter_next:integer range 0 to 900;<br><br> signal y_counter, y_counter_next:integer range 0 to 900;<br><br> --video_on_off<br><br> signal video:std_logic;<br><br>begin<br><br> --clk register<br><br> process(clk,reset,start)<br><br> begin<br><br> if reset ='1' then<br><br> counter_h&lt;=0;<br><br> counter_v&lt;=0;<br><br> hs_buffer&lt;='0';<br><br> hs_buffer&lt;='0';<br><br> <br>counter_mod2&lt;='0';<br><br> elsif clk'event and clk='1' then<br><br> if start='1' then<br><br> <br>counter_h&lt;=counter_h_next;<br><br> <br>counter_v&lt;=counter_v_next;<br><br> <br>x_counter&lt;=x_counter_next;<br><br> <br>y_counter&lt;=y_counter_next;<br><br> <br>hs_buffer&lt;=hs_buffer_next;<br><br> <br>vs_buffer&lt;=vs_buffer_next;<br><br> <br>counter_mod2&lt;=counter_mod2_next;<br><br> end if;<br><br> end if;<br><br> end process;<br><br> --video on/off<br><br> video &lt;= '1' when (counter_v &gt;= VBP) and (counter_v<br>&lt; VBP + VR) and (counter_h &gt;=HBP) and <br><br> <br>(counter_h &lt; HBP + HR) else <br><br> <br>'0'; </p><p> <br>--mod 2 counter<br><br> counter_mod2_next&lt;=not counter_mod2;<br><br> --end of Horizontal scanning <br><br> h_end&lt;= '1' when counter_h=799 else <br><br> <br>'0'; <br><br> -- end of Vertical scanning<br><br> v_end&lt;= '1' when counter_v=524 else <br><br> <br>'0'; <br><br> -- Horizontal Counter<br><br> process(counter_h,counter_mod2,h_end)<br><br> begin<br><br> counter_h_next&lt;=counter_h;<br><br> if counter_mod2= '1' then<br><br> if<br>h_end='1' then<br><br> <br>counter_h_next&lt;=0;<br><br> else<br><br> <br>counter_h_next&lt;=counter_h+1;<br><br> end<br>if;<br><br> end if;<br><br> end process;</p><p> <br>-- Vertical Counter<br><br> process(counter_v,counter_mod2,h_end,v_end)<br><br> begin <br><br> counter_v_next &lt;= counter_v;<br><br> if counter_mod2= '1' and h_end='1'<br>then<br><br> if v_end='1'<br>then<br><br> <br>counter_v_next&lt;=0;<br><br> else<br><br> <br>counter_v_next&lt;=counter_v+1;<br><br> end<br>if;<br><br> end if;<br><br> end process;</p><p> <br>--pixel x counter<br><br> process(x_counter,counter_mod2,h_end,video)<br><br> begin <br><br> x_counter_next&lt;=x_counter;<br><br> if video = '1' then <br><br> if counter_mod2=<br>'1' then <br><br> <br>if x_counter= 639 then<br><br> <br>x_counter_next&lt;=0;<br><br> <br>else<br><br> <br>x_counter_next&lt;=x_counter + 1;<br><br> <br>end if;<br><br> end if;<br><br> else<br><br> <br>x_counter_next&lt;=0;<br><br> end if;<br><br> end process;</p><p> <br>--pixel y counter<br><br> process(y_counter,counter_mod2,h_end,counter_v)<br><br> begin <br><br> y_counter_next&lt;=y_counter;<br><br> if counter_mod2= '1' and<br>h_end='1' then <br><br> if counter_v<br>&gt;32 and counter_v &lt;512 then<br><br> <br> y_counter_next&lt;=y_counter + 1;<br><br> else <br><br> <br> y_counter_next&lt;=0; <br><br> end if;<br><br> end if;<br><br> end process;</p><p> <br>--buffer<br><br> hs_buffer_next&lt;= '1' when counter_h &lt; 704<br>else--(HBP+HGO+HFP) <br><br> <br> '0';<br><br> vs_buffer_next&lt;='1' when counter_v &lt; 523<br>else--(VBP+VGO+VFP) <br><br> <br> '0'; </p><p> <br>--outputs<br><br> y_control &lt;= conv_std_logic_vector(y_counter,10); <br><br> x_control &lt;= conv_std_logic_vector(x_counter,10); <br><br> h_s&lt;= hs_buffer;<br><br> v_s&lt;= vs_buffer;<br><br> video_on&lt;=video;</p><p>end<br>Behavioral;</p><p>TEST PROGRAM</p><p>You can<br>find a test VHDL code given below to test the vhdl code of the SYNC<br>module.In this test program we connect the RGB signals to three switches.<br>According to the combination of these switches we get 8 different<br>colors on the screen.</p><p>library<br>IEEE;<br><br>use IEEE.STD_LOGIC_1164.ALL;</p><p>entity<br>sync_test is<br><br> Port ( clk : in STD_LOGIC;<br><br> <br>sw : in STD_LOGIC_VECTOR (2 downto 0);<br><br> <br>rgb : out STD_LOGIC_VECTOR (2 downto 0);<br><br> <br>hsn : out STD_LOGIC;<br><br> <br>vsn : out STD_LOGIC );<br><br>end sync_test;</p><p>architecture<br>Behavioral of sync_test is</p><p> <br>COMPONENT sync_mod<br><br> PORT( clk :<br>IN std_logic;<br><br> <br>reset : IN std_logic;<br><br> <br>start : IN std_logic; <br><br> <br>y_control : OUT std_logic_vector(9 downto 0);<br><br> <br>x_control : OUT std_logic_vector(9 downto 0);<br><br> <br>h_s : OUT std_logic;<br><br> <br>v_s : OUT std_logic;<br><br> <br>video_on : OUT std_logic );<br><br> END COMPONENT;</p><p> <br>--buffer<br><br> signal sw_next:STD_LOGIC_VECTOR (2 downto 0);<br><br> signal video:std_logic;<br><br>begin<br><br> process(clk)<br><br> begin<br><br> if clk'event and clk='1' then<br><br> <br>sw_next &lt;=sw;<br><br> end if;<br><br> end process;</p><p> <br>Inst_sync_mod: sync_mod PORT MAP( clk =&gt; clk, reset =&gt; '0', start =&gt;<br>'1', y_control =&gt; open, x_control =&gt; open,<br><br> <br>h_s =&gt; hsn, v_s =&gt; vsn, video_on =&gt; video );<br><br><br><br> rgb&lt;= &quot;000&quot; when video = '0' else<br><br> <br>sw_next ; </p><p>end<br>Behavioral;</p><p>IMG GEN( Image Generator) Module</p><p>IMG GEN<br>module will generate 3 bit RGB signal. It consists of three sub-modules.</p><p>In this<br>part we will design the objects shown on the screen. In our project we<br>will generate wall, bar and ball objects. </p><p>Wall Code</p><p>constant<br>wall_l:integer :=10;--the distance between wall and left side of screen<br><br>constant wall_t:integer :=10;--the distance between wall and top side of screen<br><br>constant wall_k:integer :=10;--wall thickness<br><br>signal wall_on:std_logic; <br><br>signal rgb_wall:std_logic_vector(2 downto 0); </p><p> <br>..................................</p><p>wall_on<br>&lt;= '1' when x &gt; wall_l and x &lt; (640-wall_l) and y&gt; wall_t and y<br>&lt; (wall_t+ wall_k) else<br><br> '0';<br><br><br>rgb_wall&lt;=&quot;000&quot;;--Black</p><p>Bar Code</p><p>signal<br>bar_l,bar_l_next:integer :=100; --the distance between bar and left side of<br>screen<br><br>constant bar_t:integer :=420;--the distance between bar and top side of screen<br><br>constant bar_k:integer :=10;--bar thickness<br><br>constant bar_w:integer:=120;--bar width<br><br>constant bar_v:integer:=10;--velocity of the bar<br><br>signal bar_on:std_logic;<br><br>signal rgb_bar:std_logic_vector(2 downto 0); </p><p> <br>...............................................</p><p>bar_on<br>&lt;= '1' when x &gt; bar_l and x &lt; (bar_l+bar_w) and y&gt; bar_t and y &lt;<br>(bar_t+ bar_k) else<br><br> <br>'0'; <br><br>rgb_bar&lt;=&quot;001&quot;;--blue</p><p>Ball Code </p><p>signal<br>ball_l,ball_l_next:integer :=100;--the distance between ball and left side of<br>screen<br><br>signal ball_t,ball_t_next:integer :=100; --the distance between ball and top<br>side of screen<br><br>constant ball_w:integer :=20;--ball Height<br><br>constant ball_u:integer :=20;--ball width<br><br>constant x_v,y_v:integer:=3;-- horizontal and vertical speeds of the ball <br><br>signal ball_on:std_logic;<br><br>signal rgb_ball:std_logic_vector(2 downto 0); </p><p> <br> .......................................</p><p>ball_on<br>&lt;= '1' when x &gt; ball_l and x &lt; (ball_l+ball_u) and y&gt; ball_t and y<br>&lt; (ball_t+ ball_w) else<br><br> <br>'0'; <br><br>rgb_ball&lt;=&quot;010&quot;; --Green </p><p>Animation</p><p>--refreshing(1/60)<br><br>signal refresh_reg,refresh_next:integer;<br><br>constant refresh_constant:integer:=830000;<br><br>signal refresh_tick:std_logic;</p><p> <br>....................................</p><p>process(clk)<br><br>begin<br><br> if clk'event and clk='1' then<br><br> refresh_reg&lt;=refresh_next;<br><br><br> end if;<br><br>end process;<br><br>refresh_next&lt;= 0 when refresh_reg= refresh_constant else<br><br>refresh_reg+1;<br><br>refresh_tick&lt;= '1' when refresh_reg = 0 else<br><br> <br>'0';</p><p>--bar<br>animation<br><br>process(bar_l,refresh_tick,button_r,button_l)<br><br>begin<br><br> bar_l_next&lt;=bar_l;<br><br> if refresh_tick= '1' then<br><br> if button_l='1' and bar_l<br>&gt; bar_v then <br><br> <br>bar_l_next&lt;=bar_l- bar_v;<br><br> elsif button_r='1' and<br>bar_l &lt; (639- bar_v-bar_w) then<br><br> bar_l_next&lt;=bar_l+<br>bar_v;<br><br> end if;<br><br> end if;<br><br>end process;</p><p>--ball<br>animation<br><br>process(refresh_tick,ball_l,ball_t,xv_reg,yv_reg)<br><br>begin<br><br> ball_l_next &lt;=ball_l;<br><br> ball_t_next &lt;=ball_t;<br><br> xv_next&lt;=xv_reg;<br><br> yv_next&lt;=yv_reg;<br><br> if refresh_tick = '1' then<br><br> if ball_t&gt; 400<br>and ball_l &gt; (bar_l -ball_u) and ball_l &lt; (bar_l +120) then --the ball<br>hits the bar<br><br> <br>yv_next&lt;= -y_v ;<br><br> elsif ball_t&lt; 35 then--The<br>ball hits the wall<br><br> <br>yv_next&lt;= y_v;<br><br> end if;<br><br> if ball_l &lt; 10 then --The ball hits the left side of the<br>screen<br><br> xv_next&lt;= x_v;<br><br> elsif ball_l&gt; 600 then <br><br> xv_next&lt;= -x_v ;<br>--The ball hits the right side of the screen<br><br> end if; <br><br> ball_l_next &lt;=ball_l +xv_reg;<br><br> ball_t_next &lt;=ball_t+yv_reg; <br><br> end if;<br><br>end process;</p><p>MUX</p><p>signal<br>vdbt:std_logic_vector(3 downto 0);</p><p>.................................</p><p>vdbt&lt;=video_on<br>&amp; wall_on &amp; bar_on &amp;ball_on; <br><br>with vdbt select<br><br> rgb_next &lt;= &quot;100&quot; when<br>&quot;1000&quot;,--Background of the screen is red <br><br> rgb_wall when &quot;1100&quot;,<br><br> rgb_wall when &quot;1101&quot;,<br><br> rgb_bar when &quot;1010&quot;,<br><br> rgb_bar when &quot;1011&quot;,<br><br> rgb_ball when &quot;1001&quot;,<br><br> &quot;000&quot; when others;</p><p>Whole Code</p><p>library<br>IEEE;<br><br>use IEEE.STD_LOGIC_1164.ALL;<br><br>use IEEE.STD_LOGIC_ARITH.ALL;<br><br>use IEEE.STD_LOGIC_UNSIGNED.ALL;</p><p>entity<br>img_gen is<br><br> Port ( clk : in STD_LOGIC;<br><br> <br>x_control : in STD_LOGIC_VECTOR(9 downto 0);<br><br> <br>button_l : in STD_LOGIC;<br><br> <br>button_r : in STD_LOGIC;<br><br> <br>y_control : in STD_LOGIC_VECTOR(9 downto 0);<br><br> <br>video_on : in STD_LOGIC;<br><br> <br>rgb : out STD_LOGIC_VECTOR(2 downto 0));<br><br>end img_gen;</p><p>architecture<br>Behavioral of img_gen is</p><p>--wall<br><br>constant wall_l:integer :=10;--the distance between wall and left side of<br>screen<br><br>constant wall_t:integer :=10;--the distance between wall and top side of screen<br><br>constant wall_k:integer :=10;--wall thickness<br><br>signal wall_on:std_logic; <br><br>signal rgb_wall:std_logic_vector(2 downto 0); <br><br><br><br>--bar<br><br>signal bar_l,bar_l_next:integer :=100; --the distance between bar and left side<br>of screen<br><br>constant bar_t:integer :=420;--the distance between bar and top side of screen<br><br>constant bar_k:integer :=10;--bar thickness<br><br>constant bar_w:integer:=120;--bar width<br><br>constant bar_v:integer:=10;--velocity of the bar<br><br>signal bar_on:std_logic;<br><br>signal rgb_bar:std_logic_vector(2 downto 0); <br><br><br><br>--ball<br><br>signal ball_l,ball_l_next:integer :=100;--the distance between ball and left<br>side of screen<br><br>signal ball_t,ball_t_next:integer :=100; --the distance between ball and top<br>side of screen<br><br>constant ball_w:integer :=20;--ball Height<br><br>constant ball_u:integer :=20;--ball width<br><br>constant x_v,y_v:integer:=3;-- horizontal and vertical speeds of the ball <br><br>signal ball_on:std_logic;<br><br>signal rgb_ball:std_logic_vector(2 downto 0); <br><br><br><br>--refreshing(1/60)<br><br>signal refresh_reg,refresh_next:integer;<br><br>constant refresh_constant:integer:=830000;<br><br>signal refresh_tick:std_logic;<br><br><br><br>--ball animation<br><br>signal xv_reg,xv_next:integer:=3;--variable of the horizontal speed<br><br>signal yv_reg,yv_next:integer:=3;--variable of the vertical speed<br><br><br><br>--x,y pixel cursor<br><br>signal x,y:integer range 0 to 650;<br><br><br><br>--mux<br><br>signal vdbt:std_logic_vector(3 downto 0);<br><br><br><br>--buffer<br><br>signal rgb_reg,rgb_next:std_logic_vector(2 downto 0);</p><p>begin</p><p>--x,y<br>pixel cursor<br><br>x &lt;=conv_integer(x_control);<br><br>y &lt;=conv_integer(y_control );</p><p>--refreshing<br><br>process(clk)<br><br>begin<br><br> if clk'event and clk='1' then<br><br> <br>refresh_reg&lt;=refresh_next; <br><br> end if;<br><br>end process;<br><br>refresh_next&lt;= 0 when refresh_reg= refresh_constant else<br><br>refresh_reg+1;<br><br>refresh_tick&lt;= '1' when refresh_reg = 0 else<br><br> <br>'0';<br><br>--register part<br><br>process(clk)<br><br>begin<br><br> if clk'event and clk='1' then<br><br> ball_l&lt;=ball_l_next;<br><br> ball_t&lt;=ball_t_next;<br><br> xv_reg&lt;=xv_next;<br><br> yv_reg&lt;=yv_next;<br><br> bar_l&lt;=bar_l_next;<br><br> end if;<br><br>end process;</p><p>--bar<br>animation<br><br>process(bar_l,refresh_tick,button_r,button_l)<br><br>begin<br><br> bar_l_next&lt;=bar_l;<br><br> if refresh_tick= '1' then<br><br> if button_l='1' and bar_l &gt; bar_v then <br><br> bar_l_next&lt;=bar_l-<br>bar_v;<br><br> elsif button_r='1' and bar_l &lt; (639-<br>bar_v-bar_w) then<br><br> <br>bar_l_next&lt;=bar_l+ bar_v;<br><br> end if;<br><br> end if;<br><br>end process;</p><p>--ball<br>animation<br><br>process(refresh_tick,ball_l,ball_t,xv_reg,yv_reg)<br><br>begin<br><br> ball_l_next &lt;=ball_l;<br><br> ball_t_next &lt;=ball_t;<br><br> xv_next&lt;=xv_reg;<br><br> yv_next&lt;=yv_reg;<br><br> if refresh_tick = '1' then<br><br> if ball_t&gt; 400 and ball_l &gt; (bar_l<br>-ball_u) and ball_l &lt; (bar_l +120) then --the ball hits <br><br> <br>the bar<br><br> yv_next&lt;= -y_v<br>;<br><br> elsif ball_t&lt; 35 then--The ball hits<br>the wall<br><br> yv_next&lt;= y_v;<br><br> end if;<br><br> if ball_l &lt; 10 then --The ball hits the<br>left side of the screen<br><br> xv_next&lt;= x_v;<br><br> elsif ball_l&gt; 600 then <br><br> xv_next&lt;= -x_v ;<br>--The ball hits the right side of the screen<br><br> end if; <br><br> ball_l_next &lt;=ball_l +xv_reg;<br><br> ball_t_next &lt;=ball_t+yv_reg; <br><br> end if;<br><br>end process;</p><p>--wall<br>object<br><br>wall_on &lt;= '1' when x &gt; wall_l and x &lt; (640-wall_l) and y&gt; wall_t<br>and y &lt; (wall_t+ wall_k) else<br><br> <br>'0'; <br><br>rgb_wall&lt;=&quot;000&quot;;--Black</p><p>--bar<br>object<br><br>bar_on &lt;= '1' when x &gt; bar_l and x &lt; (bar_l+bar_w) and y&gt; bar_t and<br>y &lt; (bar_t+ bar_k) else<br><br> <br>'0'; <br><br>rgb_bar&lt;=&quot;001&quot;;--blue</p><p>--ball<br>object<br><br>ball_on &lt;= '1' when x &gt; ball_l and x &lt; (ball_l+ball_u) and y&gt;<br>ball_t and y &lt; (ball_t+ ball_w) else<br><br> <br>'0'; <br><br>rgb_ball&lt;=&quot;010&quot;; --Green </p><p>--buffer<br><br>process(clk)<br><br>begin<br><br> if clk'event and clk='1' then<br><br> rgb_reg&lt;=rgb_next;<br><br> end if;<br><br>end process;</p><p>--mux<br><br>vdbt&lt;=video_on &amp; wall_on &amp; bar_on &amp;ball_on; <br><br>with vdbt select<br><br> rgb_next &lt;= &quot;100&quot; when &quot;1000&quot;,--Background<br>of the screen is red <br><br> rgb_wall when &quot;1100&quot;,<br><br> rgb_wall when &quot;1101&quot;,<br><br> rgb_bar when &quot;1010&quot;,<br><br> rgb_bar when &quot;1011&quot;,<br><br> rgb_ball when &quot;1001&quot;,<br><br> &quot;000&quot; when others;<br><br>--output<br><br>rgb&lt;=rgb_reg;</p><p>end<br>Behavioral;</p><p>VHDL SOURCE CODE OF THE PONG GAME</p><p>Now we<br>will combine two module just designed previous parts to complete the Pong Game<br>Module</p><p>library<br>IEEE;<br><br>use IEEE.STD_LOGIC_1164.ALL;<br><br>use IEEE.STD_LOGIC_UNSIGNED.ALL;</p><p>entity<br>vga_control is<br><br> Port ( clk : in STD_LOGIC;<br><br> <br>start : in STD_LOGIC;<br><br> <br>reset : in STD_LOGIC;<br><br> <br>button_l : IN std_logic;<br><br> <br>button_r : IN std_logic;<br><br> <br>rgb : out STD_LOGIC_VECTOR (2 downto 0);<br><br> <br>h_s : out STD_LOGIC;<br><br> <br>v_s : out STD_LOGIC);<br><br>end vga_control;</p><p>architecture<br>Behavioral of vga_control is</p><p>COMPONENT<br>img_gen<br><br> PORT( clk : IN std_logic;<br><br> <br>x_control : IN std_logic_vector(9 downto 0);<br><br> <br>button_l : IN std_logic;<br><br> <br>button_r : IN std_logic;<br><br> <br>y_control : IN std_logic_vector(9 downto 0);<br><br> <br>video_on : IN std_logic; <br><br> <br>rgb : OUT std_logic_vector(2 downto 0) );<br><br>END COMPONENT;</p><p>COMPONENT<br>sync_mod<br><br> PORT( clk : IN std_logic;<br><br> <br>reset : IN std_logic;<br><br> <br>start : IN std_logic; <br><br> <br>y_control : OUT std_logic_vector(9 downto 0);<br><br> <br>x_control : OUT std_logic_vector(9 downto 0);<br><br> <br>h_s : OUT std_logic;<br><br> <br>v_s : OUT std_logic;<br><br> <br>video_on : OUT std_logic );<br><br>END COMPONENT;</p><p>signal<br>x,y:std_logic_vector(9 downto 0);<br><br>signal video:std_logic;</p><p>begin<br><br> U1: img_gen PORT MAP(<br>clk =&gt;clk , x_control =&gt; x, button_l =&gt; button_l ,button_r =&gt;<br>button_r, <br><br> <br>y_control =&gt; y, video_on =&gt;video , rgb =&gt; rgb );</p><p> <br>U2: sync_mod PORT MAP( clk =&gt; clk, reset =&gt; reset, start =&gt; start,<br>y_control =&gt; y, x_control =&gt;x ,<br><br> <br>h_s =&gt; h_s , v_s =&gt; v_s, video_on =&gt;video );<br><br>end Behavioral;</p><p>Have fun...</p>
<p><strong><u>1.<br>Define classes and objects with respect to the real world.</u></strong></p><p>.Every vehicle has its own color, wheels, registration number and Model<br>number. In class we define them as fields, there values could be different for<br>different objects.</p><p>Each of these has their own functions like move forward, backward and stop.</p><p>So we could make many objects of class vehicle.</p><p></p><p><strong><u>2.<br>Compare structures in C with classes in C++.</u></strong></p><p>Members of a class are private by default and members of<br>struct are public by default.<br><br>For example program 1 fails in compilation and program 2 works fine.</p><br> <br> // Program 1<br> <p>#include &lt;stdio.h&gt;</p><br> <br> <p>classTest {</p><br> <p> intx; // x is private</p><br> <p>};</p><br> <p>intmain()</p><br> <p>{</p><br> <p> Test t;</p><br> <p> t.x = 20; // compiler error because x is<br> private</p><br> <p> getchar();</p><br> <p> return0;</p><br> <p>}</p><br> <br><br> <br> // Program 2<br> <p>#include &lt;stdio.h&gt;</p><br> <br> <p>structTest {</p><br> <p> intx; // x is public</p><br> <p>};</p><br> <p>intmain()</p><br> <p>{</p><br> <p> Test t;</p><br> <p> t.x = 20; // works fine because x is public</p><br> <p> getchar();</p><br> <p> return0;</p><br> <p>}</p><br> <br><p><strong><u>3.<br>What is the purpose of creating an object?</u></strong></p><p><strong>A class</strong> member can be defined as<br>public, private or protected. By default members would be assumed as private. <strong>A<br>class</strong> constructor is a special <strong>function</strong> in <strong>a class</strong> that is<br>called when a new <strong>object</strong> of the class is <strong>created</strong>. A destructor is<br>also a special <strong>function</strong> which is called when <strong>created object</strong> is<br>deleted.</p><p><strong><u>4.<br>State few lines about cin and cout.</u></strong></p><p><strong>The<br>standard output stream (cout):</strong></p><p>The predefined object <strong>cout</strong> is<br>an instance of <strong>ostream</strong> class. The cout object is said to be<br>&quot;connected to&quot; the standard output device, which usually is the<br>display screen. The <strong>cout</strong> is used in conjunction with the stream<br>insertion operator, which is written as &lt;&lt; which are two less than signs<br>as shown in the following example.</p><p>#include<br>&lt;iostream&gt;</p><p>using<br>namespace std;</p><p>int<br>main( )</p><p>{</p><p>char str[] = &quot;Hello C++&quot;;</p><p>cout &lt;&lt; &quot;Value of str is : &quot;<br>&lt;&lt; str &lt;&lt; endl;</p><p>}</p><p>When the above code is compiled and<br>executed, it produces the following result:</p><p>Value<br>of str is : Hello C++</p><p>The C++ compiler also determines the<br>data type of variable to be output and selects the appropriate stream insertion<br>operator to display the value. The &lt;&lt; operator is overloaded to output<br>data items of built-in types integer, float, double, strings and pointer<br>values.</p><p>The insertion operator &lt;&lt; may<br>be used more than once in a single statement as shown above and <strong>endl</strong> is<br>used to add a new-line at the end of the line.</p><p><strong>The<br>standard input stream (cin):</strong></p><p>The predefined object <strong>cin</strong> is<br>an instance of <strong>istream</strong> class. The cin object is said to be attached to<br>the standard input device, which usually is the keyboard. The <strong>cin</strong> is<br>used in conjunction with the stream extraction operator, which is written as<br>&gt;&gt; which are two greater than signs as shown in the following example.</p><p>#include<br>&lt;iostream&gt;</p><p>using<br>namespace std;</p><p>int<br>main( )</p><p>{</p><p>char name[50];</p><p>cout &lt;&lt; &quot;Please enter your name:<br>&quot;;</p><p>cin &gt;&gt; name;</p><p>cout &lt;&lt; &quot;Your name is: &quot;<br>&lt;&lt; name &lt;&lt; endl;</p><p>}</p><p><strong><u>5.<br>List any two advantages of using scope resolution operator.</u></strong></p><h3>Scope Resolution Operator in c++ or cpp </h3><p>- scope resolution operator is used to indicate a member of<br>a specified class.<br><br>- The scope resolution operator helps in visulization of a global variable in<br>the conten of local variable with the same name.</p><p><strong><u>6.<br>How data abstraction and encapsulation is achieved in C++?</u></strong></p>Encapsulation in C++<p><strong>Encapsulation</strong> is a process of wrapping of data and methods<br>in a single unit. It is achieved in C++ language by class concept.</p><p>Combining of <strong>state</strong> and <strong>behavior</strong> in a<br>single container is known as encapsulation. In C++ language encapsulation can<br>be achieve using <strong>class</strong> keyword, state represents declaration<br>of variables on attributes and behavior represents operations in terms of<br>method.</p><p><strong>ENCAPSULATION</strong></p><p>Encapsulation is an Object Oriented Programming concept that<br>binds together the data and functions that manipulate the data, and that keeps<br>both safe from outside interference and misuse. Data encapsulation led to the<br>important OOP concept of <strong>data hiding</strong>.</p><p><strong><u>7. How an object is represented internally in memory?</u></strong></p><p>A good understanding of how dynamic<br>memory really works in C++ is essential to becoming a good C++ programmer.<br>Memory in your C++ program is divided into two parts:</p><ul><li><strong>The stack:</strong><br> All variables declared inside the function will take up memory from the<br> stack.<li><strong>The heap:</strong><br> This is unused memory of the program and can be used to allocate the<br> memory dynamically when program runs.</ul><p><strong><u>8. What is the role of dot operator in C++?</u></strong></p>The (.) dot operator:<p>To assign the value &quot;zara&quot; to the <strong>first_name</strong> member of<br>object emp, you would write something as follows:</p><pre>strcpy(emp.first_name,&quot;zara&quot;);</pre><p><strong><u>9. </u></strong><strong><u>Give an example of<br>setter/mutator, getter/accessor and business logic functions.</u></strong></p><p>Accessing data members of a class depends upon the access<br>specifiers of these members. Sometimes there is a necessity to provide access<br>even to private data members. In this case technique of <strong>Accessors </strong>(getters) and <strong>Mutators</strong> (setters) are used.</p><p>Getters and Setters allow you<br>to effectively protect your data. This is a technique used greatly when<br>creating classes. For each variable, a get method<br>will return its value and a set method will set<br>the value.</p><p><strong><u>10. Define the scope of a class.</u></strong></p><h3>Class scope (C++ only)</h3><p>A name declared within a member function hides a<br>declaration of the same name whose scope extends to or past the end of the<br>member function's class.</p><p>When the scope of a declaration extends to or past the end of a class<br>definition, the regions defined by the member definitions of that class are<br>included in the scope of the class. Members defined lexically outside of the<br>class are also in this scope. In addition, the scope of the declaration<br>includes any portion of the declarator following the identifier in the member<br>definitions.</p>
<p>Still waiting for the PCB to arrive, but everything worked on the breadboard.</p>
<p>My LED won't blind. I do not have a 1uF capacitor. I have a 0.1uF; is this the problem? Help.</p>
<p>I doing it's don't but i smell not good?</p><p>like fire in led.</p>
<p>I made the circuit on my breadboard using various types of Capacitors, it worked really great. </p>
<p>i made it but changed the led and resistor (for the led) to a motor that does 1.5-3.0 volts. it worked at first but then the ic overheated and didn't work anymore. i also changed the R1 and R2 to resistors to 47k and 10m ohm resistors. help please!</p><p>btw, i burnt my finger :D</p>
<p>ps, i think i connected it wrong. but now i have a different problem. my motor stays on. IT WILL NOT PULSE!!!! HEEEEEEEEEEEEEEEELP!</p>
<p>What type of motor?</p>
<p>@kevindiamond1015: the 555 timer integrated circuit is not designed for the higher current draw of an electric motor. To safely drive a motor, you need additional circuitry, either a power transistor, optoisolator or relay. The power transistor option is the most common. have a look at this design http://www.instructables.com/id/Drive-Servos-with-a-555-timer-IC/</p>
<p>I followed your instructions to a T. Though some of the values on my resistors and capacitors are a little different. The light flashes but is very, very dim. When I connect to light directly to the power source the light shines good and bright. A</p><p>Any ideas why the light is so low when placed in the circuit????</p>
<p>Use lower K resistors. </p>
<p>i made this circuit and it works . thanks a lot .. i changed the value of capacitor and resistance so that the blinking becomes more fast its amazing .</p><p>visit my page techmess.page.tl</p>
<p>What was the resistance of the resistors you used?</p>
<p>How do I make the LED flash faster?!</p>
<p>What will happen if you don't use a capacitor?</p>
<p>What will happen if you don't use a capacitor?</p>
<p>1. I didn't have a 470K resistor so i added a 150K and 330K in series for a 480 and it works almost the same as when I simulated it in 123d circuits. I added my own twist to it by having a pushbutton between the diode and ground connection so it only works when I hold it.</p>
Please I need a circuit that beeps with buzzer, continuous beeping ... Smoogfk@gmail.com. Thanks
<p>How would I make it blink faster with shorter equal bursts.</p>
<p>what does pin 5 go to?</p>
<p>Pin 5 is 'Control Voltage'. It's not used in this example. Having said that, I would put a .01uF capacitor from it to ground. Basically, you'll get a much cleaner square wave.</p>
<p>This works fine. <br>What do I have to change if I use 12v power?</p>
<p>I should have also mentioned that most LED's can safely (without burning out) handle around 20mA of current. So, if you're using a 12V supply, keep the resistor value 510+ Ohms. Note: (12 - 1.7) / .020 = 515, but using a 510+ Ohm resistor won't hurt.</p>
<p>Providing your capacitor is rated for 12V+, you wouldn't need to change anything. Remember, the voltage at pin 3 is roughly 1.7V less than VCC - so, 10.3V. Using the same 1K resistor, you'd be putting 10.3mA through the LED, which is fine. It will just be a little brighter. OHM's Law, my friend. :)</p>
<p>Did what a few other mentioned about swapping a few components. Swapped out the 470k resistor for a 10k pot. Swapped 1uF for a 47uF. This will all fit nicely onto some proto board and then will be a 555 tester for me. The 10K pot gives me a great slow flash all the way up to constantly on in effect. </p>
<p>Thank you for posting this tutorial. It was well written and easy to follow. I used an 8mm 0.5W &quot;water clear&quot; red straw hat LED. </p>
it works!!
<p><u>Used this and put in a speaker instead of led.<br>Couldn't find the right capacitor so I took 3x3,3 uF in series.<br>Also put in a POT between the caps and ground.<br>Sounds goood :)</u></p>
<p>Thanks! I made it as instructed and could not get it to blink. Read some of the comments and changed R1 to 100K and it's blinking (pretty fast, but it's actually blinking!) </p>
<p>Also changed the capacitor to 10uF</p>
<p>Thanks for this will be trying tonight when I get home, am looking to get a flickering light in the end</p>
<p>use 330 ohms before led it will glow bright if you want morel life and less glow use</p><p>higher value of resistor. use a capacitor before resistor 0.1uf. it will discharge slowly</p>
<p>Hopefully this will be of use to someone... This circuit works perfectly, only with mine the LED was really dim. I spent a long time playing around with different resistor values, even replacing R3 with a jumplead. In the end I thought I would try and work out the correct resistors the &quot;proper&quot; way. I put the LED on a bench PS to find out what current it was drawing, it went up to 60mA and popped, dim all the time. You've guessed by now, a faulty LED. Changed it, all works fine. I now use the circuit in a small project box connected to a 12v Pb battery as a visual reminder to disconnect the battery when I've finished playing with it. Circuit works fine at 12v with the LED drawing 1.2 mA, around 14mw. </p>
<p>it's not blinking &lt;/3 how can I make it blink ? without changing the materials? </p>
<p>to those posting saying they hooked it up exactly as shown and it doesn't waok: either your components are not the same or possibly you have a bad 555 IC I've made several circuits with the 555 chip over the years, both flashing (alternating) lights and audio frequencies if you used a smaller capacitor you may have hit audio frequencies. If you missed the jumpers you may have not envoked a stable mode. Without seeing exactly how you hooked it up and testing the voltage at a few points, it would be impossible to accurately troubleshoot what is wrong in each case. </p>
<p>hi,is there any way to make a timer delay ON??like press the switch and 4secs after turns on the led??thankss help please thanks</p>
<p>how can i do a delay on switch with the 555timer?please i need help.</p>
<p>I messed around with it and when I added another led in series with R2, I got alternating blinking leds!The multimeter is measuring the frequency...changing capacitor and resistor changes frequency.</p>
<p>It worked after I changed the 470K&Omega; resistor for a 10M one! :D</p>
<p>is it possible to run this using some small coin battery? (1,5 or 3 V)</p>
<p>Thank you for this one! I have a question though:</p><p>is it possible to add it more leds? or do i have to change something?</p>
Thank you. This was very helpful. I'm taking Electronics in High School but we haven't gone over schematics yet (Its only the first month)But Anyway Thank You This Was Very Helpful<br>
<p>Thank you Trilesto,<br>Am new to electronics and this was a very helpfull instructable. I just added a switch for convenience. Then replaced R1 with a potentiometer.<br>It worked like magic. Went birrrrrr then slowed down to dip.... dip....and so on<br>sweet</p>
<p>I am new to electronics. This was very clear and easy to build. Thank you. Now I just need to work out how it actually works so I understand what I actually did lol :)</p>
<p>i do it on a general pcb but it doesn't work what should be the problem occuring there??</p>
<p>I'm new to electronics, and I tried making this project, but the LED just stays on solid...I've ripped it apart and restarted 10 times now..what am I doing wrong?</p>
mine only flashes once when i remove and add the battery. please help.
Thanks man, this helped me create something after trying to read schematics all day and nothing was working. I made something work and now I wanna learn more.

About This Instructable

218,864views

108favorites

License:

More by Trilesto:Flashing L.E.D. using 555 Timer 
Add instructable to: