blind navigation project

hi sir/mam,

i m new to arduino. i am doing blind navigation projects.for that i am using one ultrasonic sensor arduino,vibrators and buzzer.our tool need to detect 5 obstacles (pit, staircase,lamp post,tree,wall ).i did
program for tat except staircase.bt i m getting oscillating output and too i need too differntiate wall and lamp post.for that i made some changes in program,it correctly says wall but floor (ground)also it detect as wall.can u plz help me and correct my code.main things i need to detect pit and obstacles correctly.
can u ppl help me out to elevate my projects?

f2.ino (1.21 KB)

  if(sensorcount=10)

You probably meant to say:

  if(sensorcount==10)

or possibly:

  if(sensorcount >= 10)
++sensorcount;

Is it valid?

anilkunchalaece:

++sensorcount;

Is it valid?

Valid C++ certainly. Whether it is valid in the context of the program is another thing.

anilkunchalaece:

++sensorcount;

Is it valid?

Yes. It is shorthand for "sensorcount = sensorcount + 1;". It can also be written "sensorcount += 1;" or "sensorcount++".
When used inside an expression the ++ and -- operators work differently depending on which side of the variable they are on:

int a = 1;
int b = ++a;  // Sets a and b to 2
int c = a++;  // Sets c to 2 (the old value of a) and sets a to 3.
int d = --a;  // Sets a and d to 2.
int e = a--;  // Sets e to 2 (the old value of a) and sets a to 1

johnwasser:
:

int a = 1;

int b = ++a;  // Sets a and b to 2
int c = a++;  // Sets c to 2 (the old value of a) and sets a to 3.
int d = --a;  // Sets a and d to 2.
int e = a--;  // Sets e to 2 (the old value of a) and sets a to 1

Thanks for it..

johnwasser:
When used inside an expression the ++ and -- operators work differently depending on which side of the variable they are on:

the code is explaining well But... Can anyone explain it..

x = ++a => the ++ is on the left so it is applied before a is assigned to x (pre-increment)
x = a++ ==> the ++ is on the right so it is applied after a is assigned to x (post increment)

Never use these pre-post increment in function calls or even worse macros, as the code is hard to understand.

int sum(int a, int b) { return a + b} ;

x = 2;
z = 3;
y = sum(x++, ++z); // y = 6;

#define square(x) ((x)*(x))

a = 4;
y = square(a++); // y becomes 30 ... if you can figure out why, you understand why you should not use this.

a = 4;
a++;
y = square(a); // y = 25;

robtillaart:
a = 4;
y = square(a++); // y becomes 30 ...

y = 4*4
a = 4+1

does it a typo or i am wrong?

does it a typo or i am wrong?

You are wrong. square(0 evaluates the argument twice, resulting in it actually multiplying 5 * 6.

our tool need to detect 5 obstacles (pit, staircase,lamp post,tree,wall )

An ultrasonic sensor measures distance. It can not tell you anything about what the signal reflected off of/what the distance is to.

a = 4
and in square(a++)

the first access of a++ equates to 5 while the second access equates to 6 resulting in the product of 5 x 6

if the macro used pow(X, 2) instead it wouldnt be a problem,

k.thnks a lot.is there any mistake in the pit and obstacles detection?sometime it is showing the correct output but sometime i am getting oscillation in the output?is there any way to find the obstacles and pit in a correct manner(without calculating threshold)?

filk:
a = 4
and in square(a++)

the first access of a++ equates to 5 while the second access equates to 6 resulting in the product of 5 x 6

if the macro used pow(X, 2) instead it wouldnt be a problem,

Wanna bet? :wink:

Hi,

Can you tell me how you considered those thresholds for wall, staircase and pit?? how did you differentiate it?? I need it for my project. Can you help me?