Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to start the I2C communication as a master.
Arduino
Wire.[1](); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'start' instead of 'begin' causes a compilation error.
Trying to use 'init' or 'open' which are not Wire library functions.
✗ Incorrect
The Wire.begin() function initializes the I2C bus as a master.
2fill in blank
mediumComplete the code to send a byte of data over I2C.
Arduino
Wire.[1](0x42);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'send' or 'transmit' which are not valid Wire functions.
Confusing with other communication libraries.
✗ Incorrect
The Wire.write() function sends data bytes to the I2C device.
3fill in blank
hardFix the error in the code to request 4 bytes from a device with address 0x3C.
Arduino
Wire.requestFrom([1], 4);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong address like 0x30 or 0xC3 causes no response.
Confusing 7-bit and 8-bit addresses.
✗ Incorrect
The device address must be the 7-bit I2C address, here 0x3C.
4fill in blank
hardFill both blanks to start transmission to address 0x50 and end it properly.
Arduino
Wire.[1](0x50); Wire.[2]();
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'start' or 'stop' which are not Wire library functions.
Mixing up the order of functions.
✗ Incorrect
beginTransmission() starts communication with the device, and endTransmission() ends it.
5fill in blank
hardFill all three blanks to read bytes from a device and store them in a variable.
Arduino
int data = Wire.[1](); while(Wire.[2]()) { data = Wire.[3](); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'write' instead of 'read' to get data.
Confusing 'available' with 'read'.
✗ Incorrect
Wire.available() checks if data is ready to read, and Wire.read() reads the data byte.
