Read and Write to registers


hi,

i'm new in programming arduinouno , have example code how read , write directly various in , output data registers without using digitalwrite(), digitalread() , analogread().

all best /gg

read port:
byte value = pinx; // x = a,b,c,d etc.
write port:
porty = 0x00 oxff; // y = a,b,c,d etc.

act on single bit:
if ((pind & 0b00000100) == 0){ // bit 2 of port d for example
// bit 0, something
}
else {
// bit 1, else
}
writing single bit:
portd = portd & 0b11111011; // make bit 2 of port d 0 (clear bit), leaving rest alone
portd = portd | 0b00000100; // make bit 2 of port d 1 (set bit), leaving rest alone

have not tried same analogread, suggest you use time allowed 110us conversion.


Arduino Forum > Using Arduino > Programming Questions > Read and Write to registers


arduino

Comments

Popular posts from this blog

Error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode - Raspberry Pi Forums

class MPU6050 has no member named begin

missing filename after '-o'