Skip to main content

Featured

RELAY

RELAY A relay is like a switch that can be controlled electronically. Relays are very simple devices and can be used to control devices with higher loads(Like AC controlled devices and devices that require heavy voltages to operate). Relay modules can be used mainly in IOT projects and home automation. Relays can be used to make useful hobby projects.  A two channel relay. *Dealing with high voltages may cause injuries or even death, please use relays with utmost care. Working of Relays. Relays work like electromagnets, when a voltage is applied the coil,  the coil gets charged and acts like an electromagnet and moves the switch to the desired position. In simple terms, relays act as magnets when a signal is applied or removed. Basic circuit of a relay Connections. +5V of Arduino-  5V of relay module. GND of Arduino- GND of relay module. Pin no. 8 of Arduino- In1 of relay module. Basic connection of a relay module CODE void setup() { pinMode(8, OUTPUT); } void loop() { digitalWrite(8,

WHAT IS ULTRASONIC SENSOR AND HOW TO USE IT?

ULTRASONIC SENSOR

We all know that ultrasonic vibrations are used in an ultrasonic sensor. They are transmitted from one side and received from the other. The sensor on its own has various capabilities. For instance, we can use the sensor to make a working radar(in fact that's how they work) or make ourselves a silent pet that follows us around. The capabilities are unlimited when it comes to an ultrasonic sensor. The only thing that matters is how you use the sensor. All in all, the ultrasonic sensor maps the distance between itself and its surroundings and gives us a value we can use to our benefit.


How it works?

One side of the ultrasonic sensor sends ultrasonics waves, while the other side receives them.This constant sending and receiving help us determine the distance between the object and the sensor.
The principle of the ultrasonic is simple, just like dolphins, whales, and bats who transmit and receive ultrasonic waves the sensor sends waves and receives them.  
We can use the following formula to calculate distance in an ultrasonic sensor:
Distance= speed*time.
We will be using the pulsein function for this sensor which readily converts the duration to distance according to our needs. I will be talking about the HC-SR04 ultrasonic sensor.


THE CONNECTIONS

  • Connect VCC to +5v of the Arduino.
  • Connect GND to GND of the Arduino.
  • Connect trigpin to number 2 pin of the Arduino.
  • Connect echopin to number 3 pin of the Arduino.

THE CODE

const int trigPin = 2;
const int echoPin = 3; double duration, distance; void setup() {
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
Serial.begin(9600);} void loop() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH);
distance = (duration*.0343)/2;
Serial.print("Distance: ");
Serial.println(distance); delay(100);}

YOU CAN CALL ME OR SEND ME A MAIL TO GET YOUR PARTS FOR THE CHEAPEST PRICE... ANY TIME.

P.S.: If you have any doubt please comment or email me at robotherapyy@gmail.com

Comments

Post a Comment

Popular Posts