Question

In: Computer Science

Explain the section of code in the setup() function that implements the following instructions Wire.beginTransmission(0x68); Wire.write(0);             ...

Explain the section of code in the setup() function that implements the following instructions

Wire.beginTransmission(0x68);

Wire.write(0);              // set the address

byte sec = Wire.read();

Wire.endTransmission();     // stop transmitting

Wire.beginTransmission(0x68);

Wire.write(0);              // set the address

Wire.write(sec & 0x7F);     // clear CH bit

Wire.endTransmission();     // stop transmitting

Why is this necessary?

Solutions

Expert Solution

Wire.beginTransmission(0x68);-Begins a transmission to I2C slave device with the address 0x68.

Wire.write(0); -write() is a function that writes data over the I2C BUS.Wire.write(0) will set the address to 0.

byte sec = Wire.read(); - It will read a byte that was transmitted from slave device to master and store in sec.

Wire.endTransmission(); -Ends the transmission to slave device that had been begun by beginTransmission().

Wire.beginTransmission(0x68);-It again begins a transmission to I2C slave device with the address 0x68.

Wire.write(0); -As expained earlier Wire.write(0) will again set the address to 0.(00H)

Wire.write(sec & 0x7F); -Here sec represents seconds and & represents AND operation which is performed between seconds with bit 7 and as a result it will clear Clock Hault(CH) bit.Bit 7 of register 0 is CH bit.

Wire.endTransmission(); -Ends the transmission to slave device that had been begun by beginTransmission().

Setup() importance-It is executed only once inthe beginning of your program.This function is useful to configure the Arduino. It is used for initializing variables,pin modes etc.It is here, for example, that you put the initial configurations, such as if a LED starts off or on, which the input and output pins are, among other things.


Related Solutions

TEXT ONLY PLEASE (PLEASE NO PDF OR WRITING) C++ CODE Instructions Write a program that implements...
TEXT ONLY PLEASE (PLEASE NO PDF OR WRITING) C++ CODE Instructions Write a program that implements the algorithm given in Example 1 - 3 (Chapter 1), which determines the monthly wages of a salesperson. The instructions for Example 1 - 3have been posted below for your convenience. Example 1 - 3 Every salesperson has a base salary. The salesperson also receives a bonus at the end of each month, based on the following criteria: If the salesperson has been with...
what is the following (ARDUINO): -The digitalRead function -The correct setup for the “for” / “for...
what is the following (ARDUINO): -The digitalRead function -The correct setup for the “for” / “for next loop” control: - The analogWrite function can be used to -Serial.print() will display information on
Please write a python code which implements the counting sort algorithm by creating a CountingSort function...
Please write a python code which implements the counting sort algorithm by creating a CountingSort function with an array input in the form of a list. Then write code to sort 3 randomly generated arrays and the data array listed below, print the output clearly for all four test arrays, develop and comment on the growth function of your code. Comment on the Big O notation of the code. ( Please do not forget to comment on your code to...
Translate the C function code below to the MIPS True Assembler Language code (machine instructions only)....
Translate the C function code below to the MIPS True Assembler Language code (machine instructions only). The function code should follow the conventions for MIPS function calls including passing parameters and returning results. Your function code must be written with the minimum number of machine instructions to be executed and without any use of MIPS pseudo-instructions. Myfunction(unsigned int a, unsigned int b, unsigned int c) { int i=0; while (a > c) { a /= b; i++; } return i;...
From this information: the following code, explain which statements are instructions, which are assembly directives, which...
From this information: the following code, explain which statements are instructions, which are assembly directives, which are labels, and which are comments: ;"this"program"adds"3"to address $2000"and"increments"Accumulator"B """""""" org"$4000 ldaa"$2000 adda"#3 ;" add"3"to"(A)" staa"$2000 incb ; increment"B
Write a function that implements the following formula to calculates the amount of financial assistance for...
Write a function that implements the following formula to calculates the amount of financial assistance for families in need: • If the annual family income is between $30,000 and $40,000 and the family has at least 3 children, the assistance amount will be $1,000 per child. • If the annual family income is between $20,000 and $30,000 and the family has at least 2 children, the assistance amount will be $1,500 per child. • If the annual family income is...
Question: In the following MIPS assembly code, translate all the instructions to their corresponding machine code...
Question: In the following MIPS assembly code, translate all the instructions to their corresponding machine code in hexadecimal format. This code is stored in the memory from address 0x2fff0004. Loop: lw $t0, 4($s0)             addi $t1, $t1, -15             sll $t1, $t1, 2             beq $t1, $s1, Exit             addi $s0, $s0, 4             j Loop Exit: …
Instructions: Complete the following case study and upload it to the assignment section prior to the...
Instructions: Complete the following case study and upload it to the assignment section prior to the due date. This will contribute towards the case study portion of a student’s grade. Case study answers must be typed. Point values are assigned per question. Patient Profile M.W. is a 65-year-old female. She is a retired auto worker who lives in a condo with her golden retriever, Charlie. She has a history of diabetes type II diagnosed 3 years ago. She had a...
Using Python write a function that implements the following two-dimensional objective function: F (x, y) =...
Using Python write a function that implements the following two-dimensional objective function: F (x, y) = (x^2 + y − 11)^2 + (x + y^2 − 7 )^22 . Determine how many local minimums and maximums and their location for this objective function.
Write a Java program (use JDBC to connect to the database) that implements the following function...
Write a Java program (use JDBC to connect to the database) that implements the following function (written in pseudo code): (20 points) CALL RECURSION ( GIVENP# ) ; RECURSION: PROC ( UPPER_P# ) RECURSIVE ; DCL UPPER_P# ... ; DCL LOWER_P# ... INITIAL ( ' ' ) ; EXEC SQL DECLARE C CURSOR FOR SELECT MINOR_P# FROM PART_STRUCTURE WHERE MAJOR_P# = :UPPER_P# AND MINOR_P# > :LOWER_P# ORDER BY MINOR_P# ; print UPPER_P# ; DO "forever" ; EXEC SQL OPEN C...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT