I am currently in an introductory assembly language class. My assignment is to use a sparkfun joystick shield kit to do something with an arduino uno. I figure turning on LEDs is the easiest. We must program it in AVR assembly(note: we have only used nasm assembly all semester).
I don't really know how this needs to be done, but I would like the lights to turn on when a button is pressed (one LED per button). I also want to use the analog pins to have the joystick LEDs fade in and out.
below is the code I have right now, and don't have the equipment to test it.
Am I on the right track, or is it a horrible mess? The professor was referring to the arduino pins with hex, but I couldn't find a mapping of the pins and their hex values.
Thanks in advance.
.include "/usr/local/include/atmega32u4.def" .global main .section .text main: cbi PortD, 2 ; joystick button cbi PortD, 3 ; right button cbi PortD, 4 ; up button cbi PortD, 5 ; down button cbi PortD, 6 ; left button cbi PortC, 0 ; joystick vertical output cbi PortC, 1 ; joystick horizontal output ldi r16, 0x7c ; select pins 2-6 for button input mask in ddrd, r16 ; set digital button pins as input ldi r17, 0x03 ; select pins 0 & 1 for joystick input in ddrc, r17 ; set analog joystick pins as input ldi r18, 0x1f ; select pins 8-12 for button LED output out ddrb, r18 ; set digital button LED pins as output ldi r18, 0x0c ; select pins 2 & 3 for joystick LED ouput out ddrc, r18 ; set analog joystick LED pins as output loop: ldi r20, PortD ; read in from digital pins 0-7 and r20, r16 ; apply button input mask mov r20, r20 >> 2 ; shift left twice sts PortB, r20 ; turn on LEDs of pushed buttons ldi r20, PortC ; read in from analog pins and r20, r17 ; apply joystick input mask mov r20, r20 >> 2 ; shift left twice sts PortC, r20 ; turn on LEDs of joystick movement rjmp loop