Write the following code snippets in C for Arduino 1) A function that will set t
ID: 3832448 • Letter: W
Question
Write the following code snippets in C for Arduino
1) A function that will set the set an array to zero, the prototype should be
void ZeroIntArray( int Array[], int LengthOfArray );
2) A function that will return a true if two arrays contain the same values, the prototype will be
void IntArraysEqual( int Array1[], int Array2[], int LengthOfArray );
3) Create the enum for the states in the STD in Figure 1, along with a function that will shift between the various states, as described for each button press.
4) The basic code structure for the encoder tracker system described in the pseudocode for encoder tracking.
Explanation / Answer
1.
void ZeroIntArray( int Array[], int LengthOfArray ){
for(int i0;i<LengthOfArray ;i++)
Array[i]=0;
}
2. Prorotype is defined with void but questuon is asking to return value..Vague!! change ret type to bool or adjust accordingly
char IntArraysEqual( int Array1[], int Array2[], int LengthOfArray ){
for(int i=0;i<LengthOfArray ;i++)
{
if(Array1[i] !=Array2[i])
return 'n';
}
return 'y';
}
For enum create like this:
enum ChngeCode{ ChangCode1, ChngCode2, ChngCode3,Unlocked };
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.