Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Created by waterlubber
- _________ ________ ________
- |\___ ___\\ ____\|\ __ \
- \|___ \ \_\ \ \___|\ \ \|\ \
- \ \ \ \ \_____ \ \ _ _\
- \ \ \ \|____|\ \ \ \\ \|
- \ \__\ ____\_\ \ \__\\ _\
- \|__| |\_________\|__|\|__|
- \|_________|
- The Singing Relay
- This is liscensed under GPL V3
- http://opensource.org/licenses/GPL-3.0
- I am not liable for any damages caused by this software. Use it at your own
- risk. It is provided AS IS without any guarentees.
- -----
- This uses the relay shield from seeedstudio. http://seeedstudio.com
- You may connect a buzzer's input +5V terminal to the pins configured
- below. It requires a serial connection.
- Type in a number from 0-1000. 1000 being 500 Hz and 0 being 1 Hz.
- */
- int buzzer = 7; //Pre-Configured Pins
- int buzzer2 = 4;
- int value = 0;
- void setup() {
- Serial.begin(9600); //Serial Baud Rate 9600
- pinMode(buzzer, OUTPUT);
- pinMode(buzzer2, OUTPUT);
- }
- void loop() {
- while (Serial.available() > 0) { //Checks for data in serial buffer
- value = Serial.parseInt(); //Turns data into a number.
- Serial.println(value); //Returns the data, for troubleshooting.
- }
- digitalWrite(buzzer, HIGH);
- delay((1001 -value) / 30);
- digitalWrite(buzzer2, HIGH);
- delay(1001-value);
- digitalWrite(buzzer, LOW);
- delay((1001 - value) / 30);
- digitalWrite(buzzer2, LOW);
- delay(1001-value);
- }
Advertisement
Add Comment
Please, Sign In to add comment