ARDUINO CODE The following two values are read from a sensor by Arduino code. Ea
ID: 3688973 • Letter: A
Question
ARDUINO CODE
The following two values are read from a sensor by Arduino code. Each value can be from 0-255. Together they represent a 16 bit 2s complement number from the sensor. Write the code needed to combine the two values and produce the final value and assign it to the variable "result". Using Serial.println, display the result. Assume that all necessary setup for the Serial object has been done (i.e. just show the Serial.println statement. Int high_byte = 0times73; int low_byte = 0times37; int result;Explanation / Answer
#include #include #include #include #include #include #include #include #include #define CTRL_REG1 0x20 #define CTRL_REG2 0x21 #define CTRL_REG3 0x22 #define CTRL_REG4 0x23 int fd; int x = 0; int y = 0; int z = 0; int main (){ fd = wiringPiI2CSetup(0x69); // I2C address of gyro wiringPiI2CWriteReg8(fd, CTRL_REG1, 0x1F); //Turn on all axes, disable power down wiringPiI2CWriteReg8(fd, CTRL_REG3, 0x08); //Enable control ready signal wiringPiI2CWriteReg8(fd, CTRL_REG4, 0x80); // Set scale (500 deg/sec) delay(100); // Wait to synchronize void getGyroValues (){ int MSB, LSB; LSB = wiringPiI2CReadReg16(fd, 0x28); MSB = wiringPiI2CReadReg16(fd, 0x29); x = ((MSBRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.