IR Sensor + Vibration Motor

I have a school project where my final goal is to make a sensor blind stick that will vibrate when an object is close enough to it. I am using IR sensors and BestTong Mini Vibrating Motors as well as a nano V3. I am extremely new to arduino coding and have only coded in python. I have a code so far that lets me know that the sensor actually senses the object in front of it and then tells the user. I am unsure how to code the vibrating motor into it, as I want it to vibrate only when the sensor sees an object. This code is not mine, as I found it online and have taken out or added little bits. If you are able to assist with the wiring for the motor as well then let me know. Heres what I have so far:

int isObstaclePin = A0; // This is our input pin
int isObstacle = HIGH; // HIGH MEANS NO OBSTACLE


void setup() {
  pinMode(isObstaclePin, INPUT);
  Serial.begin(9600);
}

void loop() {
  isObstacle = digitalRead(isObstaclePin);
  if (isObstacle == LOW)
  {
    Serial.println("OBSTACLE!!, OBSTACLE!!");
  }
  else
  {
    Serial.println("clear");
  }
  delay(200);
}

What is that? What bloody thing have You got there? How would we know?

The same reply as above. Helpers are not gods having crystal balls around.

Read this link and use it: How to get the best out of this forum - Using Arduino / Project Guidance - Arduino Forum

Pay attention to "links" and "datasheets".

1 Like

Prior projects:
stick used by visually impared at DuckDuckGo

Google:
arduino small motor driver circuit at DuckDuckGo

int isObstacle = HIGH; // HIGH MEANS NO OBSTACLE

#define Vibrator 13;
void setup() {
  pinMode(isObstaclePin, INPUT);
pinMode(Vibrator, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  isObstacle = digitalRead(isObstaclePin);
  if (isObstacle == LOW)
  {
digitalWrite (Vibrator, HIGH);
    Serial.println("OBSTACLE!!, OBSTACLE!!");
  }
  else
  {
digitalWrite (Vibrator, LOW);
    Serial.println("clear");
  }
  delay(200);
} ```

You don't even need Arduino for this project
You can simply connect ir sensor directly with vibrator using gnd and data pin

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.