Can somebody tell me how to set only specific pins in a port to be output. I dont want to use all of them just specific ones. I have found code to make all the pins output:
With most processors, the data direction register will set a bit as output with the corresponding bit the DDR low (say) and as an input with the bit high (say).
So if the DDR has 8 bits and you wanted bit 2 as an output and the rest as inputs you would write 11111011 to the DDR.
If you wanted bit 1 and bit 6 as outputs then you'd write 10111101 to the DDR and so on.
In other words, it all depends on the bit pattern that you write to the DDR.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.