SNAKE GAME ENSAMBLADOR 1

SNAKE GAME ENSAMBLADOR 1


we are students of the University of Cauca this project is a practical digital circuitry of the subject It is based on the development of the classic game of Culebrita We will use microcontroller PIC16F877A for displaying the use Culebrita a matrix of LEDs 8×8 connected to the ports 8-bit microcontroller Now let’s talk about the operation of an array of LEDs good as any array it consists of a row and columns the technique to turn a LED on
the matrix is ​​in place a one in any row any of the eight rows and place a zero in any communes so that if
put 1 in this row here placed a zero in the commune also zero and worn
the LED Corner the same would with any of the other leds once known the operation of each of the components, we proceed to implement another series of elements that allow the proper functioning circuit here is the matrix of LEDs We have the microcontroller in this case the f 16 8 7 7 to the
microchip and we can see a series of resistors which they are connected in this case to
microcontroller port C these resistors are also connected the rows of the matrix, which makes this port is to send me one to this the port B is connected to the cathodes each pin array with
to send the zeros then the intersection of each of the one from this port I generated or comprises a led me to the intersection of zero to send this port that way we can see a glass four Mhz I generated oscillation frequency for the operation of the microcontroller we can also see four pushbuttons which they are used in this case for
the direction of the little snake right left, up and down is connected so that Submit a microcontroller placing a resitencias in this 100ohm and these resistors are 10K and finally we have the reset button that resets the microcontroller me This is the assembler code for the game Culebrita initially we created all records
we will use later also we assign a sort of pseudonyms to C and B ports and pins which we will use as inputs pushbuttons to provide us with the creation of
code Start settings do
the port as input ports b and c ports as outputs
timer settings that later use We clean all ports to believe
previously Starting Program We create an initial position for
head here we create also we create a starting position for the food
going to be fixed it will be denoted by com call these values ​​after
com We call food food and they go to
draw values ​​com bone, transfers them to the ports and then I appear in the matrix after that clean rows
rows that if we clean rows no longer appear me
the matrix therefore when call wall and start assigning values
columns and rows I will not generate any errors wall we do is draw
wall of the womb then draw column by column and row by row 1
a row after one another after column after another and comparing each drawing position if
the position of the head is there for in that case is lost then the head position
It will be given by a record called column and another record It called row then we use the bits less
significant of these requirements compare them with the least significant bits of records that keep me
wall in that case if they are equal It is lost in the game and me going to your routine is called
you lost thereafter here we reward clean some accountants have called food
column and food row if already
have reached four because the to generate the random use
tables and these tables are small then no
if they exceed this value we generate an error in the program after ensure that they are not to be greater than 4 we go to a subroutine that is called
start buttons I start to push what we do is initially we do the same
verify that the records that go me generating position
food not exceed the value of 4 and we begin to wonder which switches are activated in the beginning restricted which can not be start pulses to detect the
buttons that go me to the wall because in the initial position the
head was against the wall in a corner only have two options stripping after we come to inico buttons and we return if not is not used no key it generates an infinite loop me and I will repeat the same action several times same action many times therefore I was going to look encendios all leds
before we mentioned that are initial head position and the initial position of the column This is what we see in isis this initial state Yes I do not I press any button I will keep the initial state
This will be the initial state food we place and this will be the head assign
this will be the wall that generate after generating the initial position what we do is proceed to the subroutine
detection others buttons that initially we did in
the initial state right now we will create several subroutines for detecting
in several cases pushbuttons In the first case we do call
a subroutine left pushbuttons in this case initially we will do the same thing
and we had done before to verify that the counters that I
they will be increasing to generate the random signal of food I do not exceed the value of 4 then and now
there are four we reset again and what we do is detect each of buttons indicated in the case that
I am in buttons on left it means the little snake is turning toward the
right therefore if I press
left and not You will not have to repay so it is not necessary to detect it then I will detect only
button up or down so if I detect right or
Left she does not make me anything simply I continued where it is here depending on which button is
activated subroutine will each button He is assigned for movement that we do with each with the other subroutine what will make
without right buttons when the Culebrita this by turning
left We do the same with counters
the random signal the philosophy is the same in the
detection pushbuttons then we do not push up that same principle will be based
here we increase one of the I values ​​will generate random food and we do exactly the same as the
previous without buttons down here in also we do exactly the same which means that little snake is
going up Thus if I will not be able so I return it will not affect
button down or up because she is already going up once the detection of the fact
pushbuttons the subroutines we address the
I will I subroutines will move the
head the little snake initially We use these records called
pull pres which is what will save me the position of the position of the button the last button to be has
down when the
the last button was pressed is which he gives me the way to the right as
He kept one we make call the initial values ​​of the head which they are row and column these row and column will always be
fixed and I will maintain the position the current head then we moved here to
our ports to draw them in matrix We call a subroutine that is called
compare this subroutine will compare what I
to do tell me if the food is It does not matter to the head then register here compared with
food log record column that keeps me food values
current and that keeps me column values the current head also bought Row row
food and row of the head if equal We call a subroutine that is called
new com in this subroutine what we do is generate and our random signal for the food in this your subroutine what we do is
have a draw here with values fixed which with the intersection d d both will give me a LED on the matrix to be our column then we do good as we always reset these counters if they and their
value has reached four because our as we see our table
It is small and if we exceed that value it is possible that it the code give us an error then what we do is to decode the value which each accountant in that instant Y what we do is move the current values ​​of food which they are food column and row column in both cases always use a
register and one column for row that will give me the intersection and that intersection is the I will draw a point in the matrix after what call our com and its subroutine and
We have assigned to entries I keep the current position of the
food a new value to be random
because we do not know because They are increasing those counters
Each press or if not pressed anything I will also be increasing

13 thoughts on “SNAKE GAME ENSAMBLADOR 1

Leave a Reply

Your email address will not be published. Required fields are marked *