Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to include the Wire library for I2C communication.
Arduino
#include [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Including SPI.h instead of Wire.h
Forgetting the angle brackets <> around the library name
✗ Incorrect
The Wire library is included with #include to use I2C communication.
2fill in blank
mediumComplete the code to initialize the Serial communication at 9600 baud.
Arduino
void setup() {
Serial.[1](9600);
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using Serial.start instead of Serial.begin
Using Serial.init which does not exist
✗ Incorrect
Serial communication is started with Serial.begin(baud_rate).
3fill in blank
hardFix the error in the code to read data from the Wire library.
Arduino
Wire.[1]();
int data = Wire.read(); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using write instead of requestFrom
Using beginTransmission when reading data
✗ Incorrect
To read data from a device, Wire.requestFrom(address, quantity) is used.
4fill in blank
hardFill both blanks to send data using SPI library.
Arduino
SPI.[1](); SPI.[2](0xFF);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using SPI.write which is not a standard SPI function
Forgetting to call SPI.begin before transfer
✗ Incorrect
SPI communication starts with SPI.begin() and sends data with SPI.transfer().
5fill in blank
hardFill all three blanks to initialize Servo and set its position.
Arduino
#include <Servo.h> Servo [1]; void setup() { [1].[2](9); [1].[3](90); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using begin() instead of attach() for Servo
Not naming the Servo object
✗ Incorrect
Create a Servo object named myServo, attach it to pin 9, then write 90 degrees.