View the step-by-step solution to:

int array = { 13, 12, 11, 10}; int array2 = { 6, 5, 4, 3}; int array3 = { A2, A3, A4, A5}; int En = 2; int pos = A0; int Load = A1; int roll1 = 9;...

Please describe every step of the attached 4 bit up/down counter Arduino code and draw schematic (LED, DIP switches, Arduino Mega), and flowchart, please write every \description in the code.
int array [] = { 13, 12, 11, 10}; int array2 [] = { 6, 5, 4, 3}; int array3 [] = { A2, A3, A4, A5}; int En = 2; int pos = A0; int Load = A1; int roll1 = 9; int roll2 = 8; void setup () { for( int q = 0; q < 4; ++ q) { pinMode( array [q], OUTPUT ); } for (int w = 0; w < 4; ++ w) { pinMode( array2 [w] , INPUT ); } pinMode( En, INPUT ); pinMode( pos, INPUT ); pinMode( Load, INPUT); Serial.begin(9600); } void loop () { int w = 0; int en = digitalRead (En); int L = digitalRead (Load); int val1 = digitalRead (array2 [0]); int val2 = digitalRead (array2 [1]); int val3 = digitalRead (array2 [2]); int val4 = digitalRead (array2 [3]); int POS = digitalRead (pos); int va1 = digitalRead (array3 [0]); int va2 = digitalRead (array3 [1]); int va3 = digitalRead (array3 [2]); int va4 = digitalRead (array3 [3]); int Roll1 = digitalRead (roll1); int Roll2 = digitalRead (roll2); //Serial.print (Roll2); int B = 0; if ( val1 == 1) B = B + 1; if ( val2 == 1) B = B + 2; if ( val3 == 1) B = B + 4; if ( val4 == 1) B = B + 8; int x = 0; if ( va1 == 1) x = x + 1; if ( va2 == 1) x = x + 2; if ( va3 == 1) x = x + 4; if ( va4 == 1) x = x + 8; int roll1Val = x;
Background image of page 01
if ( L == 1) { Serial.println ("Load On"); delay(500); digitalWrite (array [0], val1); digitalWrite (array [1], val2); digitalWrite (array [2], val3); digitalWrite (array [3], val4); } if (L == 0) { if (en == 0) Serial.println("enable off"); { digitalWrite (array [0], LOW); digitalWrite (array [1], LOW); digitalWrite (array [2], LOW); digitalWrite (array [3], LOW); } if (en == 1) { Serial.println ("enable on"); delay(10); if ( Roll1 == 1)//enable roll { for ( int a = 0; a <= roll1Val; a ++) { Serial.print ("Roll up: \t"); Serial.println (a); if ( a == 0) { digitalWrite (array [0], LOW); digitalWrite (array [1], LOW); digitalWrite (array [2], LOW); digitalWrite (array [3], LOW); } if ( a == 1) { digitalWrite (array [0], HIGH); digitalWrite (array [1], LOW); digitalWrite (array [2], LOW); digitalWrite (array [3], LOW); } if ( a == 2) { digitalWrite (array [0], LOW); digitalWrite (array [1], HIGH); digitalWrite (array [2], LOW); digitalWrite (array [3], LOW); } if ( a == 3) { digitalWrite (array [0], HIGH); digitalWrite (array [1], HIGH); digitalWrite (array [2], LOW); digitalWrite (array [3], LOW); } if ( a == 4) { digitalWrite (array [0], LOW);
Background image of page 02
Show entire document
Sign up to view the entire interaction

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question