Arduino uno AVR assembly with LEDs 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 &amp; 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 &amp; 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 &gt;&gt; 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 &gt;&gt; 2       ; shift left twice
        sts     PortC, r20          ; turn on LEDs of joystick movement
        rjmp    loop
Did you know that the Arduino Uno uses the Atmel ATmega328P processor?

using the ADC for analog input in assembly language

You may want to skim through Chapter "24. Analog-to-Digital Converter" of the ATmega328P datasheet.

You may want to read application note "AVR126: ADC of megaAVR in Single Ended Mode" and browse through the corresponding AVR126 example software.
(It's in the C language, but it mentions all the registers you'll need to read the ADC in your assembly language program).
(As you can tell from the ATmega328 datasheet, the ATmega88 has exactly the same ADC as the ATmega328).

"Assembler source code for the conversion of an analogue voltage to an 8-bit-number",
"AVR ASM Introduction: A moron's guide to ADC"
and
"ATmega8 ADC Example"
have a pure assembly language program for reading the ADC on a Atmel AVR chip
-- alas, on a slightly different chip that may have slightly different registers than the ATmega328P.

Good luck!