Complete the code to import the SMBus module needed for I2C communication.
from smbus2 import [1]
The SMBus class from smbus2 is used to communicate over I2C.
Complete the code to create an SMBus object for I2C bus number 1.
bus = SMBus([1])On Raspberry Pi, I2C bus 1 is commonly used for communication.
Fix the error in the code to write a single byte command 0x20 to the device at address 0x40.
bus.write_byte([1], 0x20)
The first argument to write_byte is the I2C device address, which is 0x40 in this case.
Fill both blanks to write a block of data [0x01, 0x02, 0x03] to register 0x10 of device 0x50.
bus.write_i2c_block_data([1], [2], [0x01, 0x02, 0x03])
The first argument is the device address (0x50), the second is the register address (0x10).
Fill all three blanks to write the value 0xFF to register 0x01 of device 0x60 using write_byte_data.
bus.write_byte_data([1], [2], [3])
The first argument is the device address (0x60), the second is the register (0x01), and the third is the data byte (0xFF).
