EasyManua.ls Logo

SunFounder 3in1 Kit - Page 163

Default Icon
351 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
SunFounder 3in1 Kit
How it works?
About the application of ultrasonic sensor, we can directly check the subfunction.
float readSensorData(){// ...}
The trigPin of the ultrasonic module transmits a 10us square wave signal every 2us
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
The echoPin receives a high level signal if there is an obstacle within the range and use the pulseIn() function to
record the time from sending to receiving.
microsecond=pulseIn(echoPin, HIGH);
The speed of sound is 340 m/s or 29 microseconds per centimeter.
This gives the distance travelled by the square wave, outbound and return, so we divide by 2 to get the distance of the
obstacle.
float distance = microsecond / 29.00 / 2;
Note that the ultrasonic sensor will pause the program when it is working, which may cause some lagging when writing
complex projects.
4.5.9 5.9 ShiftOut(LED)
shiftOut() will make 74HC595 output 8 digital signals. It outputs the last bit of the binary number to Q0, and the
output of the first bit to Q7. In other words, writing the binary number “00000001” will make Q0 output high level and
Q1~Q7 output low level.
In this project, you will learn how to use 74HC595. 74HC595 consists of an 8bit shift register and a storage register
with threestate parallel outputs. It converts serial input into parallel output so you can save IO ports of an MCU.
Specifically, 74hc595 can replace 8 pins for digital signal output by writing an 8-bit binary number.
Binary number - Wikipedia
Required Components
In this project, we need the following components.
Its definitely convenient to buy a whole kit, here’s the link:
Name ITEMS IN THIS KIT LINK
3 in 1 Starter Kit 380+
You can also buy them separately from the links below.
4.5. 5. More Syntax 159

Related product manuals