Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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.

x Q 09-state diagram x C Chegg studyIGuided so x Kansas State University x C Secure https:// state instructure.com/courses/34187/files/folder/Lab Assignments?preview 3781476 Lab7 Spring 2017.pdf 2/3 box ECE 24 Lab 7-Programming Chng Code bueron Press atten Presa Chung Code 1 code Y batten Press UnLocked 2 Chn code a Combe button Press Chng Code 3 button Press Figure 1. STD for State of the Lock. Pseudo Code for Encoder Tracking. Global integer variable oldEncoder osition 01 ir 200 milliseconda has paased if Encoder position OldEncoder osition. increment appropriate digit based on atate. else if Encoder Fosition OldEncoder Position Decreatent appropriate digit based on state. 01dancoder Position Encode Poaition Spring 2017 O Download 0 Info Close Files

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 };