How is works inputs?

Hello i am really new bie an arduino and i am little bit confused about analogRead method.

Briefly, i am useing gas sensor in my project when data came up 2000 value spark core send me Sms with sms api.

Loop method is below.

Gas = analogRead(A0);

if (gas > 2000 ) {

Sendsms(); // sms function

With this code when i put sensor on board working. But when i take sensor and useing spark core alone it is automaticly send data above to 2000 and send sms.

The questionis why spark core working without sensor why A0 send data without any sensor ?

Someone can explain this ? Or
what can i do ? I need some control ?


When nothing is attached to a pin, we call it a floating pin so it can be any value.

Since you mentioned it triggers, then mostly likely the pin is reading some voltage which gives 200 and above.

One way you can do is to add something we call a pulldown resistor. 10kohm should be fine. from A0 to ground. So when nothing it connected, the A0 pin will read 0.

So how can i control this ? Is there any way ?

See my edited post above.


Ok. Got it. Thanks for your help :slight_smile:

1 Like

@Yasin, what @kennethlimcp said is correct and what you need. The pulldown resistor keeps the core analog pin to ground until your sensor sends voltage (signal) to the core analog pin (more current than 10K ohm can pull to ground) and triggering your sms.

A pull-down resistor works in the same way I*(as a pull-up resistor) but is connected to ground. It holds the logic signal near zero volts when no other active device is connected.

More info on Pull-up / Pull-down Resistors: Wikipedia

(Side Note: Helping so I am not a slacker - inside joke between Ken and I)

1 Like