Search code examples
assemblyarduinoledpins

How to turn on pins 13 and 12 at the same time? Assembly


How to turn on pins 13 and 12 at the same time?

ldi r18,0x20  ; bit 5 (pin 13) = high
out 5,r18     ; output to port B

ldi r18,0x10  ; bit 4 (pin 12) = high 
out 5,r18     ; output to port B

Solution

  • Just bitwise OR the values together to set both;

    ldi r18,0x30  ; 0x20 (bit 5) OR 0x10 (bit 4) = 0x30 sets bit 4 and 5 high
    out 5,r18     ; output to port B