write adress binary I2C

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
P@T
Posts: 33
Joined: Tue Nov 06, 2018 2:37 pm

write adress binary I2C

Post by P@T » Tue Sep 21, 2021 1:02 pm

Hi,

how to write the addresses in one go? I use a nucleoF411RE

Code: Select all

AD0 = Pin('PA0', Pin.OUT)
AD1 = Pin('PA1', Pin.OUT)
AD2 = Pin('PA4', Pin.OUT)

Code: Select all

AD2	AD1	AD0		Sequence I2C
0	0	0		0100 0000
0	0	1		0100 0010
0	1	0		0100 0100
|	|	|			|
|	|	|			|
|	|	|			|
|	|	|			|
|	|	|			|
1	1	1		0100 1110
Thank you

P@T
Posts: 33
Joined: Tue Nov 06, 2018 2:37 pm

Re: write adress binary I2C

Post by P@T » Tue Sep 21, 2021 1:55 pm

Code: Select all

my_addresse = 0b010

AD0.value(my_address & 0b001)
AD1.value(my_address & 0b010)
AD2.value(my_address & 0b100)
like this ?

P@T
Posts: 33
Joined: Tue Nov 06, 2018 2:37 pm

Re: write adress binary I2C

Post by P@T » Tue Sep 21, 2021 4:28 pm

I did this

Code: Select all

for my_address in range (7):
	AD0.value(my_address & 0b001)
	AD1.value(my_address & 0b010)
	AD2.value(my_address & 0b100)
	
	print(com.scan())
perfect ;)

Post Reply