Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Smart walking stick for blind

Status
Not open for further replies.

R raksha

New Member
For this project, i am using arduino nano
here is the code
Code:
const byte trigPin = 3; //Trigger pin of 1st Sesnor
const byte echoPin = 2; //Echo pin of 1st Sesnor
const int Buzz = 13; //Echo pin of 1st Sesnor
//const int Remote = A0; //Echo pin of 1st Sesnor
const int Light = A1; //Echo pin of 1st Sesnor
const int Water = A4;
const int led = 5;

unsigned long distance;
unsigned long duration;
//int Signal;
int Intens;
//int similar_count;
int WS;
int freq = 50;

void setup() {

pinMode(Buzz,OUTPUT);
digitalWrite(Buzz,LOW);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(Water, INPUT);
pinMode(Light, INPUT);
pinMode(led, OUTPUT);
Serial.begin(9600);
}


void loop() {
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = duration * 0.034 / 2;
  if (distance<30)

  {
    Serial.println("Object Alert");
    Serial.print("Distance: ");
    Serial.println(distance);
    int i=0;
    do
    {
      i++;
      tone(Buzz, 450);
      delay(200);
      noTone(Buzz);
      delay(200);   
    }while(i<2);
    delay(3000);
  }


//Signal = analogRead(Remote);
  Intens = analogRead(Light);

  if (Intens<=300)
  {
    digitalWrite(led, HIGH);
    Serial.print(Intens);
    Serial.println("Low Light");
    int j=0;
    do
    {
      j++;
      tone(Buzz, 450);
      delay(200);
      noTone(Buzz);
      delay(200);
    }while(j<3);
    delay(3000);
  }




//Check if Remote is pressed
/*int temp = analogRead(Remote);
similar_count=0;
while (Signal==temp)
{
Signal = analogRead(Remote);
similar_count++;
}*/

//If remote pressed
/*if (similar_count<100)
{
  Serial.print(similar_count); Serial.println("Remote Pressed");
  digitalWrite(Buzz,HIGH);delay(3000);digitalWrite(Buzz,LOW);
}*/

//If very dark

  WS = analogRead(Water);
  if (WS > 200)
  {
    Serial.println("Water presence");
    Serial.print("Water : ");
    Serial.println(WS);
    int z=0;
    do
    {
      z++;
      tone(Buzz, 450);
      delay(200);
      noTone(Buzz);
      delay(200);
    }while(z<4);
    delay(3000);
  }


//Serial.print("dist=");
//Serial.println(cm);
//Serial.print("Similar_count=");
// Serial.println(similar_count);
//Serial.print("Intens=");
//Serial.println(Intens);
//Serial.print("Water");
//Serial.println(WS);
}
what mistake is there i am not getting output for ultrasonic sensor,ldr
any suggestion please
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top