Code
Your code
has the following characteristics:
·
Has
an ultrasound distance sensor on pins 12 and 13
·
Has
an RGB LED on pins 9, 10, and 11
·
Has
two functions,
o
getdistance
(from the lab) which sends a pulse from the ultrasound sensor, measures the
echo time and returns the distance of the nearest object,
o
checkdistance,
which uses the distance to determine the appropriate color of the LED (red for
close, then orange, yellow, green, blue as the object moves further away). In this function you will need to determine
what distances you will set for each color transition. You may also need to vary the values sent to
each pin on the RGB LED to get the right colors.
Data Collection
Once
your code is compiled and uploaded to your Arduino, run the Arduino. You can use your hand as the object. Move it from the close to far and observe the
color changes from redàblue
Deliverables:
In
Gradescope (https://www.gradescope.com/) you should submit the following
files:
1.
Your
Arduino Code
2.
A
diagram of your circuit (you can submit a hand sketch, use powerpoint, or use tinkercad
(tindercad.com) to create the diagram) as an image
3.
A
flow chart diagraming your code (you can do this by hand, with powerpoint, or
with https://www.draw.io/ )
4.
A
short video demonstrating your code and circuit running and explaining what is
happening. You can also attend office
hours Thursday or Friday to demonstrate your code. Items 1, 2, and 3 should
already be in gradescope (submitted on time) before visiting office hours.
Get Free Quote!
441 Experts Online