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

Coding: Write accurate, executable code to make the Arduino perform a simple, de

ID: 3804112 • Letter: C

Question

Coding: Write accurate, executable code to make the Arduino perform a simple, defined function. For this competency assignment, you need to create an Arduino program that takes input from an IR distance sensor and controls an LED (you can use the default LED connected to pin 13 on the Arduino board) as follows: If no object is within range of the sensor, the LED is not lit. If an object is between 20 and 30 cm away from the sensor, the LED is lit. If an object is between 50 cm and 80 an away from the sensor, the LED blinks 5 times per second. You should include the following in your submission (pdf or doc only. Arduino.ino fries are not acceptable). 1. One paragraph and a photo or drawing that shows how the sensor and LED are connected to the Arduino. 2. A flowchart that describes the process executed by the loop() function 3. Your complete Arduino code WITH comments explaining the function of each line. 4 A youtube video link showing your demonstration of the code. Please show the distance measured using a ruler/measuring tape and the LED blinking in the video. (you can make the Video unlisted if you don't want it to be public) In this CT you will be using multiple if statements' to write jour code. An example code snippet on how to implement if statements is given below. Checking for grades B and E corresponding to Competency Points:/*This program turns off an LED when ct points correspond to a B and turns on an LED when CT pants correspond to an E */int ct points, //stores the total ct points scored by the student void setup() {pinMode (13, OUTPUT);//pin 13 where LED is connected is an Output pin} void loop() {if((ctpoints = 13))//check if ct points are between 13 and 14 {digitWrite(13, LOW);//Turn off the LED connected to pin 13} if(ctpoints

Explanation / Answer

Code for Arduino program-

Int ledPin=13 (LED connected to Pin 13)

Void Setup ()

{

PinMode(ledPin, OUTPUT);

}

int led1 = 25; (Object between 20 to 30)

int led2 = 60; (Object between 50 to 80)

void setup ()

{

PinMode (led1, OUTPUT)

PinMode (led2, OUTPUT)

}

Void loop()

{

if (cobject>20) && (cobject<30) /*Check if object is between 20 to 30 C.M and LED is lit*/

{

digitalWrite(25, LOW)

}

if (cobject>50) && (cobject,80) /*Object is between 50 C.M. to 80 C.M. and LED blinks 5 times per second*/

digitalWrite(60, HIGH)

}

digitalWrite(led1, LOW) */Turn the LED off*/

delay();

{

digitalWrite(led2, HIGH) */Turn the LED On*/

delay();

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote