EMBEDDED PROGRAMMING

HERE IS THE PROGRAM FOR MY CIRCUIT

;

;

 

.include "tn45def.inc"

.def           temp2 = r16

.def temp = R17; temporary storage

.def temp1 = R18; temporary storage

 

.cseg

.org 0

rjmp reset

 

;

; delay

;

.equ count = 255

delay:

   ldi temp1, count

   delay_loop1:

      ldi temp, count

      delay_loop:

         dec temp

         brne delay_loop          

      dec temp1

      brne delay_loop1

   ret

;

; main program

;

reset:

   ldi         temp2,0b00000110
                 out            PORTB,temp2
                 out            DDRB,temp2

                 clr temp2

                 ldi temp2,0b00000000

                 rcall delay

                 rcall         delay

                 rjmp start

   start:

      sbic Pinb,3

      rjmp start

      rjmp  lights

 

lights:

                 ldi temp2,0b00000110

                 out portb,temp2

                 rcall delay

                 rcall delay

        ldi    temp2,0b00000000

                 out  portb,temp2

                
rcall         delay

                 rcall         delay

                 ldi temp2,0b00000110

                 out portb,temp2

                 rcall delay

                 rcall delay

       

        rjmp start1

start1:

                 sbic pinb,3

                 rjmp start1

                    ldi         temp2,0b00000000

                 out  portb,temp2

                
rcall         delay

                 rcall         delay

                 ldi             temp2,0b00000000

                 out  portb,temp2

                
rcall         delay

                 rcall         delay

                 rjmp    start

                                 

 

HERE ARE PICS FOR PROGRAMMED CIRCUIT

BUTTON NOT PRESSED

BUTTON PRESSED

YEA IT DOES WORK!