Go Down

Topic: arduino robot (Read 365 times) previous topic - next topic

fiza95

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.

SMM2

"Success is not built on success. It's built on failure. It's built on frustration. Sometimes its built on catastrophe."

fiza95

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 http://henrysbench.capnfatz.com/henrys-bench/arduino-sensors-and-input/arduino-sound-detection-sensor-tutorial-and-user-manual/#comment-1430

PaulS

Quote
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?

fiza95

#4
Oct 15, 2016, 03:43 pm Last Edit: Oct 16, 2016, 03:43 am by Coding Badly
This is the first program which is sound sensor program that i found.

Code: [Select]

//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: [code] [/code] tags added.

SMM2

#5
Oct 15, 2016, 04:16 pm Last Edit: Oct 15, 2016, 04:24 pm by SMM2
Quote
What i want is to make the robot move when detect any sound
Code: [Select]
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.



"Success is not built on success. It's built on failure. It's built on frustration. Sometimes its built on catastrophe."

fiza95

I'm sorry but can you write the full combination code for me because i didn't know where to put your given code.

SMM2

fiza95 I'm not trying to be rude but this is your project as you said here:
Quote
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.
"Success is not built on success. It's built on failure. It's built on frustration. Sometimes its built on catastrophe."

PaulS

Quote
This is the first program which is sound sensor program that i found.
Post a link to the hardware that that code is supposed to work with. I have never seen a sound detector that generated a digital output.

Coding Badly


@fiza95, do not cross-post.  Other thread removed.


Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy