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);
}