This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
measuring_distance_with_arduino_and_ultrasound [2017/08/29 03:12] glassgiant [The Completed Circuit] |
measuring_distance_with_arduino_and_ultrasound [2017/09/23 21:16] glassgiant [Coding] |
||
---|---|---|---|
Line 10: | Line 10: | ||
{{ : | {{ : | ||
===== About the SR-04 ===== | ===== About the SR-04 ===== | ||
- | There are four pins: //Vcc// and //GND//, which supply power to the module, // | + | There are four pins: //Vcc// and //GND//, which supply power to the module, // |
+ | |||
+ | The pulse is a 40kHz audio tone, which is too high a frequency for humans to hear. | ||
+ | |||
+ | The formula | ||
+ | |||
+ | So, if we have an object in front of our sensor, and it takes 5ms for our pulse to bounce off it and be detected by our sensor, we get the following formula, where distance is in cm, time in ms and speed of sound is cm per ms: | ||
+ | |||
+ | '' | ||
+ | |||
+ | '' | ||
+ | |||
+ | '' | ||
===== Wiring the SR-04 ===== | ===== Wiring the SR-04 ===== | ||
Line 23: | Line 35: | ||
===== Wiring the Common Anode RGB LED ===== | ===== Wiring the Common Anode RGB LED ===== | ||
- | * Plug the LED into the breadboard so the pins are on different numbered rows | + | * Plug the LED into the breadboard so the pins are on different numbered rows. It's helpful to plug the longest pin, the common anode, into a different lettered column (not shown on the diagram). |
* Use a red jumper between the common anode pin (the longest pin) and the power bus | * Use a red jumper between the common anode pin (the longest pin) and the power bus | ||
* For each of the remaining pins, plug a resistor to connect the row the pin is in to the same row, but the other side of the breadboard, as shown in the diagram. | * For each of the remaining pins, plug a resistor to connect the row the pin is in to the same row, but the other side of the breadboard, as shown in the diagram. | ||
- | * Use a red, green, and blue jumper to connect the end of resistors opposite the LED to Arduino pins 9, 10 and 11. It doesn' | + | * Use a red, green, and blue jumper to connect the end of resistors opposite the LED to Arduino pins 6, 5, and 3. It doesn' |
===== Coding ===== | ===== Coding ===== | ||
- | The code for this workshop | + | The code for this lesson |
===== The Completed Circuit ===== | ===== The Completed Circuit ===== | ||
+ | This example shows an LED changing from white to red when someone gets within about 60cm of it, but the outputs could be easily changed to be more LEDS, motors, servos, sound circuits, etc. | ||
+ | |||
{{: | {{: | ||
{{: | {{: |