Go Down

Topic: Please Help :D (Read 946 times) previous topic - next topic


Hello there... new to the forums. Hello all!. I'm new to arduino and C programming. I'm familiar with programming in assembly language and was wondering if i could get a little assistance in a particular function i want to accomplish. Im using a distance sensor and want to compare readings from two different directions and have it decide which direction has a greater distance. In assembly i could store data and do a mathematical comparison to decide. Haven't been able to figure out how in C.

Distance 1 Data Read
Distance 2 Data Read
Distance 1 - Distance 2 = X
X>0 ; Do something
X<0; Do something else

Thanks in Advanced :D


Read the data into variable.
Compare the variables.

Code: [Select]

int distance1 = getDistanceFromWhateverDeviceThisIs(0);
int distance2 = getDistanceFromWhateverDeviceThatIs(1);

if (distance1 > distance2) {
  // Do something
} else {
  // Do something else


thank you... i will try this out :D

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131