Carol Zhang
Published © GPL3+

Sound-Following Robot

A sound-following robot using two microphone sensors on the TI-RSLK MAX!

BeginnerFull instructions provided748
Sound-Following Robot

Things used in this project

Hardware components

TI Robotics System Learning Kit TI-RSLK
Texas Instruments TI Robotics System Learning Kit TI-RSLK
×1
DAOKI High Sensitivity Microphone Sensor
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Energia
Texas Instruments Energia

Story

Read more

Schematics

Fritzing Diagram

Code

Sound-Following Robot

C/C++
//Carol Zhang - 2020 TI Summer Design Challenge - Sound-Following Robot

#include "Energia.h"
#include "SimpleRSLK.h"

const int leftMic = 9;
const int rightMic = 10;

boolean leftReading = 0;
boolean rightReading = 0;

void setup() {
  
  Serial.begin(115200);
  delay(1000);
  setupRSLK();

  //Set microphone sensors to be system input
  pinMode(leftMic, INPUT);
  pinMode(rightMic, INPUT);
}

void loop() {

  bool hit_obstacle = false;
  Serial.println("Searching for sound...");
  enableMotor(BOTH_MOTORS);

  setMotorDirection(LEFT_MOTOR, MOTOR_DIR_FORWARD);
  setMotorDirection(RIGHT_MOTOR, MOTOR_DIR_FORWARD);
  
  //Check microphones for sound
  rightReading = digitalRead(rightMic);
  leftReading = digitalRead(leftMic);
  
  if (leftReading==LOW && rightReading==LOW) 
  { 
    Serial.println("No sound detected!");
  }
  else if (leftReading==LOW && rightReading==HIGH)
  {
    //If sound detected on the right, robot will turn right
    Serial.println("Sound detected on the right!");
    setMotorSpeed(RIGHT_MOTOR, 10);
    delay(2350);
  }
  else if (leftReading==HIGH && rightReading==LOW)
  {
    //If sound detected on the right, robot will turn left
    Serial.println("Sound detected on the left!");
    setMotorSpeed(LEFT_MOTOR, 10);
    delay(2350);
  }
  else 
  {
    //If sound detected on the both mics, robot will move forward
    Serial.println("Sound detected from both microphones!");
    setMotorSpeed(BOTH_MOTORS, 10);
    delay(2350);
  }

  disableMotor(BOTH_MOTORS);
}

Credits

Carol Zhang

Carol Zhang

1 project • 0 followers

Comments