गुरुवार, 29 जुलाई 2021

How to Add And Simulate Ultrasonic Sensor Library to Proteus

An ultrasonic sensor is an instrument that measures the distance to an object using ultrasonic sound waves.

An ultrasonic sensor uses a transducer to send and receive ultrasonic pulses that relay back information about an object’s proximity.  


 download ckt and code..

ckt.



watch video for more information..


code..

// defines pins numbers

const int trigPin = 9;

const int echoPin = 10;

 

// defines variables

long duration;

long distance;


void setup() {

pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output

pinMode(echoPin, INPUT); // Sets the echoPin as an Input

Serial.begin(9600); // Starts the serial communication

}

 

void loop() {

// Clears the trigPin

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

 

// Sets the trigPin on HIGH state for 10 micro seconds

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);

 

// Reads the echoPin, returns the sound wave travel time in microseconds

duration = pulseIn(echoPin, HIGH);

 

// Calculating the distance

distance= duration*0.034/2;


  Serial.print(distance);

  Serial.println("  CM ");

}

LCD 16x2 scrolling text display with Arduino in Poteus....

 download ckt and code...

#include <LiquidCrystal.h>

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;

LiquidCrystal lcd(rs, en, d4, d5, d6, d7);


void setup() {

  lcd.begin(16, 2);

 }


void loop() {

  lcd.clear();

  lcd.setCursor(2, 0);

   lcd.print("SANI EDU TECH");

  for (int i = 0; i < 13; i++) {

   lcd.scrollDisplayLeft();

   delay(200); 

    

     }

}

 

watch video..



रविवार, 25 जुलाई 2021

Bidirectional Visitor Counter with Light Control using Arduino

 download  code and circuit....

#include <Wire.h>

#include <LiquidCrystal.h>


LiquidCrystal lcd(6,5,4,3,2,1);

 #define inSensor 7

#define outSensor 8

 

int inStatus;

int outStatus;

 

int countin = 0;

int countout = 0;

 

int in;

int out;

int now;

 

#define relay 9

void setup() {

 lcd.begin(16,2);

  pinMode(inSensor, INPUT);

  pinMode(outSensor, INPUT);

  pinMode(relay, OUTPUT);

  digitalWrite(relay, LOW);

 lcd.setCursor(0,0); // put your setup code here, to run once:

lcd.print("Visitor counter");

delay(1000);


}


void loop() {

   inStatus =  digitalRead(inSensor);

  outStatus = digitalRead(outSensor);

  if (inStatus == 1)

  {

    in = countin++;

  }

 

  if (outStatus == 1)

  {

    out = countout++;

  }

 

  now = in - out;

 

  if (now <= 0)

  {

    digitalWrite(relay, LOW);

    lcd.clear();

     lcd.setCursor(0,0); // put your setup code here, to run once:


    lcd.print("No Visitor");

    lcd.setCursor(0,1);

    lcd.print("Light Off");

    delay(500);

  }

  else

  {

    digitalWrite(relay, HIGH);

 

   lcd.clear();

     lcd.setCursor(0,0);

    lcd.print("Current Visitor");

  

    lcd.print(now);

 

   lcd.setCursor(0,1);

    lcd.print("IN: ");

    lcd.print(in);

 

   lcd.setCursor(8,1);

    lcd.print("OUT: ");

    lcd.print(out);

 

    

    delay(500);

  }

       }



3.5 " TFT LCD shield

                                                                                                                                            ...