Arduino programing

Hi, I would like to find out whether below arduino programing is workable.

void loop()
{
val = analogRead(0); // read input value
if (val < 101)
{
digitalWrite(2, HIGH); //send signal to digital pin #2 in case input variable is smaller then 101
delay(1000);
digitalWrite(2, LOW);
delay(1000);
} else if (val > 100 && val < 201) {
digitalWrite(3, HIGH); //send signal to digital pin #3 in case input variable is greater then 100 and smaller then 201
delay(1000);
digitalWrite(3, LOW);
delay(1000);

I will connect just normal digital indicator which widely used for weight check(used wil loadcell).
This digital indicator will give between 0~5V DC voltage variables to arduino's analog input pin(0) whenever it gets signal from loadcell.
I want to ask you two questions.
(1) Let's say that the digital indicator is displaying 150, and send DC voltage(to arduino analog input) which corresponds to digital value 150, then the value arduino gets after the analog to digital conversion process is also 150?
(2) I want my arduino to send 40mA digital signal to another arduino when the variable received from analog input pin is greater then 100 and smaller then 201. Is above programming is suitable for my intention?

Thank you.

The analog read function works by converting a voltage in the range 0 - 5 Volts to a number in the range 0 - 1023.

So the value you get from AnalogRead depends on the voktage present on the analog pin you are reading.

so for the values you use (0 -200) it would only do anything if the voltage present on the analog pin is in the range
0 - 976 mV if the voltage exceedes 976 mV your code will not change the state of any of the digtal pins.

So basically you must know what voltage your sensor is putting out.

It is possible to change the upper voltage limit that AnalogRead is looking at, by using the AREF function. Search the forum for this, it was duĂ­scussed in a very recent thread.

MikMo

Thank you for your advise as it is highly appreciated.