Secondary Menu

Interface Ultrasonic Sensor and Servo to Photon

About: I am an electronic hobbyist on Arduino, Photon, Raspberry Pi and common electronics.A passionate cook.Any assistance in electronics and web development feel free to contact me at appytechie.at@gmail.com.
More About callmeappytechie »

Hey !! I'm Sridhar Janardhan back with another ibles today I am going to show how to interface ultrasonic sensor and servo to Photon.This ibles teach you to control servo motors depending upon the values thrown by the ultrasonic sensor to the photon

Before we begin to have a look at the official website of the particle, click here

Let's now gather the component

Step 1: Components Gathering

Components required to perform this ibles are:

Photon

ultrasonic sensor

Servo

breadboard

jumper wires

Step 2: Setting Up Photon

To setup, a photon makes sure you achieve the blinking blue on the board led by holding the mode button for few seconds.

then download the official particle Android app from the play store and log in with your account credentials you had submitted in the particle website

Press the plus button in the bottom right of the screen and then select photon and continue the on screen instruction of the app and finally, you will be able to connect the photon to the wifi

Step 3: Connecting Ultrasonic Sensor

Ultrasonic sensor will work on the transmitting and reflection of the wave.the echo pin of the sensor will emit the wave form and travel through space and reflects back as soon as it obstructs an object.the time taken for the emission and reflection is calculated thus predicting the distance of the object.

The connection of the ultrasonic sensor is as follows:

VCC pin: to the positive or 3.3v pin of the photon

GND pin: to the GND pin of the photon

TRIG pin: to the digital pin 2

ECHO pin: to the digital pin 3

Step 4: Connecting Servo Motor:

Servo motor is a specially designed motor for the control of the acceleration of the shaft and its angular rotation in both directions.

The connection of the servo is as follows:

Red wire: this is the positive power supply of the servo and is connected to the 3.3 v pin of the photon

Black wire: this is the ground supply of servo and is connected to the gnd pin of the photon

orange wire: this is the signal wire which is connected to the digital pin 3 of the photon.

Step 5: Coding

#include "Servo.h"const int trigPin = 15;

const int echoPin = 13;

long duration;

int distance;

int safetyDistance;

Servo myservo; // create servo object to control a servo // twelve servo objects can be created on most boards