Bird
0
0
Arduinoprogramming~10 mins

Wire library for I2C in Arduino - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to start the I2C communication as a master.

Arduino
Wire.[1]();
Drag options to blanks, or click blank then click option'
Astart
Bopen
Cinit
Dbegin
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.
2fill in blank
medium

Complete the code to send a byte of data over I2C.

Arduino
Wire.[1](0x42);
Drag options to blanks, or click blank then click option'
Awrite
Bsend
Ctransmit
Dput
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'send' or 'transmit' which are not valid Wire functions.
Confusing with other communication libraries.
3fill in blank
hard

Fix 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'
A0x30
B0xC3
C0x3C
D0x03
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong address like 0x30 or 0xC3 causes no response.
Confusing 7-bit and 8-bit addresses.
4fill in blank
hard

Fill 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'
AbeginTransmission
Bstart
CendTransmission
Dstop
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'start' or 'stop' which are not Wire library functions.
Mixing up the order of functions.
5fill in blank
hard

Fill 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'
Aavailable
Cread
Dwrite
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'write' instead of 'read' to get data.
Confusing 'available' with 'read'.