Last active
January 20, 2024 18:37
-
-
Save warengonzaga/a51d4402fcc9e995672340b8c3d97312 to your computer and use it in GitHub Desktop.
Electronic Ultrasonic Emitter (Project E.U.E) - Basic Version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Electronic Ultrasonic Emitter (Project E.U.E) - Basic Version | |
* by Waren Gonzaga | |
* Version: 1.0.6 | |
* | |
* A simple project that emits ultrasonic waves and possible to repel mosquiotoes. | |
* Check this project on Instructables.com | |
* Link: https://www.instructables.com/id/Electronic-Ultrasonic-Emitter-Basic-Version/ | |
* | |
* Contribute to improve this project on gist! | |
* Link: https://gist.github.com/WarenGonzaga/a51d4402fcc9e995672340b8c3d97312/ | |
* | |
* This project is made possible by the following. | |
* Hive Electronics | |
* Connected Cities | |
* | |
* Having Trouble? | |
* Please email me here: warengonzaga.dev@gmail.com | |
* or Just send a quick message to my facebook page. | |
* Link: https://facebook.com/warengonzagaofficialpage | |
* Follow me on twitter: @waren_gonzaga | |
* Visit my website: https://warengonzaga.com/ | |
* | |
* Licensed under Creative Commons BY-NC-SA | |
* Copyright © 2017 Waren Gonzaga | |
*/ | |
// Speakers | |
int speaker = 11; // Digital Pin 11 | |
// Lights | |
int led_blue = 2; // Digital Pin 2 | |
int led_green = 3; // Digital Pin 3 | |
int led_red = 4; // Digital Pin 4 | |
// Frequency | |
int frequency = 40000; // 40KHz (adjust it between 20KHz to 65KHz) | |
//Are you using RGB? | |
int withRGB = 1; // 1 = true and 0 = false; | |
void setup(){ | |
// Setting Up the Outputs | |
pinMode(speaker, OUTPUT); | |
pinMode(led_blue, OUTPUT); | |
pinMode(led_green, OUTPUT); | |
pinMode(led_red, OUTPUT); | |
// initializing (light indicator) | |
if (withRGB == 1) { | |
initTesting(); | |
} else { | |
speakerTest(); | |
} | |
} | |
void loop(){ | |
// dragonfly frequency | |
tone(speaker, frequency); | |
if (withRGB == 1) { | |
blinkyIndicator(); | |
} | |
} | |
void speakerTest() { | |
// testing speaker sound | |
tone(speaker, 600); | |
delay(1000); | |
// last testing of speaker | |
tone(speaker, 700); | |
} | |
void initTesting() { | |
digitalWrite(led_blue, HIGH); | |
delay(100); | |
digitalWrite(led_blue, LOW); | |
delay(100); | |
digitalWrite(led_green, HIGH); | |
delay(100); | |
digitalWrite(led_green, LOW); | |
delay(100); | |
digitalWrite(led_red, HIGH); | |
delay(100); | |
digitalWrite(led_red, LOW); | |
delay(500); | |
digitalWrite(led_blue, HIGH); | |
delay(2000); | |
// testing speaker sound | |
tone(speaker, 600); | |
digitalWrite(led_blue, LOW); | |
delay(1000); | |
digitalWrite(led_green, HIGH); | |
delay(2000); | |
// last testing of speaker | |
tone(speaker, 700); | |
digitalWrite(led_green, LOW); | |
delay(50); | |
digitalWrite(led_green, HIGH); | |
delay(50); | |
digitalWrite(led_green, LOW); | |
delay(50); | |
digitalWrite(led_green, HIGH); | |
delay(50); | |
digitalWrite(led_green, LOW); | |
} | |
// optional, delete this if you are not using RGB | |
void blinkyIndicator() { | |
// light indicators | |
digitalWrite(led_blue, HIGH); | |
delay(100); | |
digitalWrite(led_blue, LOW); | |
delay(1000); | |
digitalWrite(led_green, HIGH); | |
delay(50); | |
digitalWrite(led_green, LOW); | |
delay(20); | |
digitalWrite(led_green, HIGH); | |
delay(50); | |
digitalWrite(led_green, LOW); | |
delay(1000); | |
digitalWrite(led_red, HIGH); | |
delay(50); | |
digitalWrite(led_red, LOW); | |
delay(5000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you take this emmitter and make two. Input into each emitter your voice at two ultrasonic frequencies that are say 4khz apart. You will be able to talk to someone in a zone where the two emmitters cross. This will be a great haloween trick. A sound someone can only hear at a specific spot in front of your house.