Need help with your Discussion

Get a timely done, PLAGIARISM-FREE paper
from our highly-qualified writers!

glass
pen
clip
papers
heaphones

Arduino Coding Computer Science Task

Arduino Coding Computer Science Task

Arduino Coding Computer Science Task

Description

 

Predict the outcomes of programs in Arduino involving conditional and looping statements

Draw an activity diagram to accomplish a given task

  • Write a program (in Arduino) corresponding to a given activity diagram
  • Here are some Arduino coding questions, along with their answers, to help you practice more: Extra Arduino Coding help.pdf
  • Actions

Submission format

Centered at the top write the name of this activity. Centered in a line below it write your name. Below these, the rest of the activity starts, aligned to the left.
Be very organized, neat, and professional. You should use consistent spacing, formatting, font, and style, as well as correct grammar and spelling.

Please type the answers to various parts as instructed below. Neatly organize all your answers in a numbered list (with sub lists) corresponding to various parts (and subparts).
You want the grader to find all your work in a convenient way lest you may lose points. 

In the end, you will submit everything as a single, typed, PDF file. 

Instructions

Complete the following parts

Part 1: Predict the result of an Arduino program
What will the following Arduino code print on the serial monitor? Try not to paste this code into Arduino, infer it by yourself and type the answer.
int x = 1;
void setup() {
  Serial.begin(9600);
}
void loop() {
  if (x < 10) {
    Serial.println(x);
    x = x+1;  }
  else {
    Serial.println(x);
   }
}

Part 2: Predict the result of an Arduino program
What will the following Arduino code make the motor do? Explain in less than 3 sentences, no “essays” please.
You may want to revisit the Arduino coding from previous week’s activity and videos for this question. In this setup, a motor is connected to the output pins of an L298n or L293d board, and the input pins of this board are connected to an Arduino’s pin 11 and pin 10. Thus, these two pins control the motor. Assume the board is already enabled. A distance sensor  (HCSR04) is also connected to Arduino. Its trigger is connected to pin 2, and echo is connected to pin 3.
Here is the code:
int motorPin1 = 11;
int motorPin2 = 10;
int trigger_pin = 2;
int echo_pin = 3;
long pulse_duration, distance_in_inches;

void setup() {
pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);
pinMode(trigger_pin, OUTPUT);
pinMode(echo_pin, INPUT);
Serial.begin(9600);
}

void loop() {
  // read the distance
  digitalWrite(trigger_pin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigger_pin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigger_pin, LOW);
  pulse_duration = pulseIn(echo_pin, HIGH);
  distance_in_inches = pulse_duration / 147.82; 

  Serial.println(distance_in_inches);
  delay(10);

  // do stuff
    if (distance_in_inches > 10) {
    digitalWrite(motorPin1, HIGH);
    digitalWrite(motorPin2, LOW);
  } else {
     if (distance_in_inches < 2) {
        digitalWrite(motorPin1, LOW);
        digitalWrite(motorPin2, HIGH);
     } else {
        digitalWrite(motorPin1, LOW);
        digitalWrite(motorPin2, LOW);
     }
  }
}

Part 3: Arduino program from a given flowchart
Here is a flow chart/activity diagram of some algorithm. Please write a complete Arduino code which will accomplish the same.
Hint:  you can always make the circuit in TinkerCAD and test your code to see if it works!

coding_assignment.png

Part 4: Flowchart for a given algorithm
There is a straight road many miles long. The road is black in color, but it has a white line/strip running in its middle. A car (shown as a red rectangle) is supposed to travel on the white line. The car is driven by a motor system, and there are two color sensors in front of the car. The color sensors are marked by two black dots on the red car as shown in the figure below, and each color sensor can see the color of the road directly below where they are mounted.
car_on_road.png

Draw a flowchart/activity diagram (not the Arduino code) which can eventually be run on some Arduino like system, which will drive the car forward on the white line/strip.
Initially the car starts in the position as shown above. The two sensors are on the white line, and car is moving forward (i.e. no steering). The car would have moved forward perfectly, but it can veer off due to random effects beyond your control. If the car veers off the white line, then the flowchart algorithm should direct it to steer back onto the white line again.

In the boxes of the flowchart, you are only allowed to use the following phrases/words or their combinations. No regular English sentences are allowed in this flowchart. The allowed phrases/words are:

start

turn left

turn right

move forward (no steer)

is the left sensor seeing white?

is the left sensor seeing black?

is the right sensor seeing white?

is the right sensor seeing black?

yes

and

no

 

 

User generated content is uploaded by users for the purposes of learning and should be used following Studypool’s honor code & terms of service.

Have a similar assignment? "Place an order for your assignment and have exceptional work written by our team of experts, guaranteeing you A results."

Order Solution Now

Our Service Charter


1. Professional & Expert Writers: Eminence Papers only hires the best. Our writers are specially selected and recruited, after which they undergo further training to perfect their skills for specialization purposes. Moreover, our writers are holders of masters and Ph.D. degrees. They have impressive academic records, besides being native English speakers.

2. Top Quality Papers: Our customers are always guaranteed of papers that exceed their expectations. All our writers have +5 years of experience. This implies that all papers are written by individuals who are experts in their fields. In addition, the quality team reviews all the papers before sending them to the customers.

3. Plagiarism-Free Papers: All papers provided by Eminence Papers are written from scratch. Appropriate referencing and citation of key information are followed. Plagiarism checkers are used by the Quality assurance team and our editors just to double-check that there are no instances of plagiarism.

4. Timely Delivery: Time wasted is equivalent to a failed dedication and commitment. Eminence Papers are known for the timely delivery of any pending customer orders. Customers are well informed of the progress of their papers to ensure they keep track of what the writer is providing before the final draft is sent for grading.

5. Affordable Prices: Our prices are fairly structured to fit in all groups. Any customer willing to place their assignments with us can do so at very affordable prices. In addition, our customers enjoy regular discounts and bonuses.

6. 24/7 Customer Support: At Eminence Papers, we have put in place a team of experts who answer all customer inquiries promptly. The best part is the ever-availability of the team. Customers can make inquiries anytime.

We Can Write It for You! Enjoy 20% OFF on This Order. Use Code SAVE20

Stuck with your Assignment?

Enjoy 20% OFF Today
Use code SAVE20