hello everyone.i'm doing arduino robot right now for my final year project.But my professor said it is very simple so i decided to change it to alarm runaway robot.But the problem is i don't know how to combined sound sensor program with arduino robot program.i'm attach the arduino robot program below and if anyone can help me i'm really thanks about that.My problem right now is i want sound sensor to detect any sound alarm and when it detect the robot will run until i switch it off.
Thanks for your help but i'm sorry the video didn't show any program but just an explanation about the robot.Basically what i want to do is to combine sound sensor program with an automatical arduino robot program which using ultrasonic sensor.So whenever the robot detect the sound it'll start to move around automatically.I've already found sound sensor program from this link
what i want to do is to combine sound sensor program with an automatical arduino robot program which using ultrasonic sensor.So whenever the robot detect the sound it'll start to move
So, you have a program that can read the sound sensor, and do something with the data.
You have a program that contains what you want to do. Combining them should be trivial. What have you tried? What were the results?
This is the first program which is sound sensor program that i found.
//Henry's Bench
//Arduino Sound Detection Sensor Module
int soundDetectedPin = 10; // Use Pin 10 as our Input
int soundDetectedVal = HIGH; // This is where we record our Sound Measurement
boolean bAlarm = false;
unsigned long lastSoundDetectTime; // Record the time that we measured a sound
int soundAlarmTime = 500; // Number of milli seconds to keep the sound alarm high
void setup ()
{
Serial.begin(9600);
pinMode (soundDetectedPin, INPUT) ; // input from the Sound Detection Module
}
void loop ()
{
soundDetectedVal = digitalRead (soundDetectedPin) ; // read the sound alarm time
if (soundDetectedVal == LOW) // If we hear a sound
{
lastSoundDetectTime = millis(); // record the time of the sound alarm
// The following is so you don't scroll on the output screen
if (!bAlarm){
Serial.println("LOUD, LOUD");
bAlarm = true;
}
}
else
{
if( (millis()-lastSoundDetectTime) > soundAlarmTime && bAlarm){
Serial.println("quiet");
bAlarm = false;
}
}
}
And the second one is ultrasonic sensor which i've already attach from the previous post.
I've been try to combine void setup with void setup together and void loop with void loop together as i've seen a video about that.
But it didn't work well because the robot still move when i switch it on.What i want is to make the robot move when detect any sound
Moderator edit: </mark> <mark>[code]</mark> <mark>
What i want is to make the robot move when detect any sound
if (soundDetectedVal == HIGH) //Doesn't detect a sound...
{
//Brake left motor
//Brake right motor
}
else if (soundDetectedVal == LOW) // If we hear a sound...
{
//What you want your robot to do
}
Maybe something like this? And I'm not sure if this code is perfect because of the fact that I put it together in a few minutes. So please let me know if something is wrong.
fiza95 I'm not trying to be rude but this is your project as you said here:
i'm doing arduino robot right now for my final year project.
Therefore, I'm not going to do your project for you
And if you're confused where to put my code, it's going to be in the void loop. Basically it's going to be constantly checking whether there is a sound, or not. And if not, the robot will be at stand still, but if there is a sound, you will put the code in those brackets of what you want your robot to do. Which what I understood is you want it to go into obstacle avoidance mode until there is no more sound.