Difference between revisions of "Ultrasonic Sensor (HC-SR04) + Raspberry Pi"
Jump to navigation
Jump to search
Line 7: | Line 7: | ||
==Wire setup== | ==Wire setup== | ||
+ | |||
==Software== | ==Software== | ||
===Python=== | ===Python=== | ||
− | + | '''Create a new script''' | |
[[File:Newscript.png|thumbnail]] | [[File:Newscript.png|thumbnail]] | ||
− | + | '''Save your script as ultrasonic_distance.py''' | |
− | + | * Go to File and click on Save as | |
− | + | * In the field Save in browse for the C: drive and then select a folder to save in | |
− | + | * For the field File name type in ultrasonic_distance.py | |
− | + | * In the field Save as type select All Files | |
+ | * Click on Save | ||
+ | '''Open up the terminal''' | ||
+ | * Click on the monitor icon on the top of the screen | ||
+ | '''Type cd "folder name" to change directory to your pythonpractice folder, and hit Enter''' | ||
+ | '''Type ultrasonic_distance.py and hit Enter to run your program''' | ||
==TroubleShooting the pi== | ==TroubleShooting the pi== | ||
[[Category:HowTos]] | [[Category:HowTos]] |
Revision as of 17:13, 2 May 2017
Hardware
- Raspberry pi 3
- Ultrasonic Sensor - HC-SR04
- A set of resistors for each sensor you are connecting
- 330Ω and 470Ω
- Jumper wires to connect the sensor(s) to the pi
Wire setup
Software
Python
Create a new script
Save your script as ultrasonic_distance.py
- Go to File and click on Save as
- In the field Save in browse for the C: drive and then select a folder to save in
- For the field File name type in ultrasonic_distance.py
- In the field Save as type select All Files
- Click on Save
Open up the terminal
- Click on the monitor icon on the top of the screen
Type cd "folder name" to change directory to your pythonpractice folder, and hit Enter Type ultrasonic_distance.py and hit Enter to run your program