0

Basic understanding and using a tilt sensor
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Basic understanding and using a tilt sensor

by daunce on Sun Dec 30, 2018 7:18 pm

Hi. I'm new to electronics and trying to understand the example at https://learn.adafruit.com/tilt-sensor/ ... ilt-sensor.

I'm using a Particle board. [I used the product name but couldn't post the message. Link to docs below has been edited. "Your message contains banned spam words. Please rephrase your post without the following words...."], so there's a few minor changes in board layout and code.

The picture with the AA batteries makes sense as it's a complete circuit/loop (what's the proper terminology?). I created this on the breadboard and I can make the LED turn on/off depending on the tilt.

I'm a bit confused with the picture including the Arduino board. It's a complete circuit but with an extra wire to pin2.

So the questions I have:
1) When you do digitalRead(inPin), is that just checking if there's voltage/power (again, what's the proper terminology) running through the loop?
2) Does it matter where in the circuit you connect the wire from pin2?
3) It references outPin=13, and turns it HIGH/LOW but there's nothing connected to that pin in the picture. What is that supposed to do?

I copied the breadboard example, and sent the output to putty, but the output wasn't consistent. When I tilted the board, it would usually change state, but sometimes the result was 0 when tilted, other times it was 1 when tilted. Sometimes it would change state without any movement, and appeared to result in 0 for 5 digitalRead's (1 per second), then 1 for 5 reads in a continuous pattern. When the wire on pin2 was removed, it would still have changes to its state. I couldn't make any sense of it, and called it a night.

4) Docs at https://docs.particle.io/reference/devi ... gitalread- say it returns HIGH or LOW, but it didn't say if that's an int, string, boolean etc. The code in the examples use int. Is that right?

It's both exciting and frustrating learning this. It brings back memories of anxiety while waiting for code to compile to see if it's successful ;-)

Let me know if there's more info you need. Appreciate any help.

Cheers.

daunce
 
Posts: 1
Joined: Sun Dec 30, 2018 6:17 pm

Re: Basic understanding and using a tilt sensor

by franklin97355 on Sun Dec 30, 2018 7:28 pm

1) When you do digitalRead(inPin), is that just checking if there's voltage/power (again, what's the proper terminology) running through the loop?
It is checking if there is voltage on the pin however it gets there.

2) Does it matter where in the circuit you connect the wire from pin2?
The wire to pin 2 needs to be switched by the tilt sensor which is acting as a switch to ground.

3) It references outPin=13, and turns it HIGH/LOW but there's nothing connected to that pin in the picture. What is that supposed to do?
Pin 13 on most Arduino boards is connected to the onboard LED so setting it HIGH will turn on the LED.

franklin97355
 
Posts: 21072
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Please be positive and constructive with your questions and comments.