Change bit in a byte?

I want to change a bit whose location in a byte I choose, whose value I choose.

~ I have byte:
~ I write at location 3 bit 1
and the byte should become

I tried this, with no luck:

You mean like this,

I have divide the length into two half and worked but if the procedure want to repeat for particular length then have to work a few more with the blocks

Or look for this extension

But this will convert dec to binary

your blocks only seem to work if i want to change bit value at a predefined location,
but i want to be able to change the bit in a byte whose position I choose, and whose value (1 or 0) i choose

i need something like this: bitWrite() - Arduino Reference

btw that addon only does conversion

Try this one bitinabyte.aia (8.1 KB)

Or this


Thanks! Your solution looks the most simple and it most importantly actually works, so again, thanks.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.