Pages: [1]   Go Down
Author Topic: Reading Voltage from my body?  (Read 911 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all!

First off, I'm completely new to Arduino, electronics, and the forum so this might be a simple answer...

Goal:
I'm trying to build a circuit with a tilt switch in it.  When the switch is closed, I want the arduino to recognize it and turn on an LED.

Problem:
The circuit works, sort of.  For awhile the LED was flashing for no apparent reason with the tilt switch in the open position.  I disconnected the tilt switch section from the circuit completely and the LED would still flash.  I discovered that if *I* grabbed a wire connected to a ground pin the flashing would stop and the tilt switch would operate somewhat normally.  I say somewhat because it takes a few seconds for the arduino the recognize that the switch is open again when I tip it back.

EDIT:  Oh also, if I bring my hand closer to the LED while not touching a ground wire, the flashing intensifies.  If I move away from the LED, it calms down and stops.

Question:
What's going on?  Is the arduino so sensitive that it's reading voltage from my body?  I'm assuming that I'm doing something wrong here...

Set Up:
 5V -> 3300Ω Pull up Resistor -> Tilt Switch -> Pin 12

Pin 4 -> 2200Ω Pull up Resistor -> Tiny lil green LED -> Ground

EDIT: Schematic Image Attached


Code:

#define led 4
int input = 12;
int count = 0;
int val = 0;

void setup () {

  Serial.begin(9600);
  pinMode(led,OUTPUT);
  pinMode(input, INPUT);

}


void loop() {

  val = digitalRead(input);



if (val == HIGH) {

  digitalWrite(led, HIGH);
  Serial.println(val);

}
else {
  
  digitalWrite(led, LOW);
  Serial.println(val);

}

}


* Screen shot 2013-04-26 at 9.41.55 PM.png (25.65 KB, 719x664 - viewed 21 times.)
« Last Edit: April 26, 2013, 11:43:40 pm by wretrop » Logged

India
Offline Offline
Full Member
***
Karma: 0
Posts: 177
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Can you upload the schematic so that it would be much clear??`
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Schematic Uploaded
Logged

Johannesburg. UTC+2
Online Online
Faraday Member
**
Karma: 108
Posts: 4723
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Those aren't pull-ups, those are series resistors. That happens to be right for the LED (edit: although you might like to re-think the value), but you need to wire the switch something like this.

HTH....
Logged

The Elders of the Internet know who I am
I'm on LinkedIn: http://www.linkedin.com/in/jimbrownza

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 150
Posts: 5666
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You need this in "setup()":

Code:
  pinMode(input, INPUT);
  digitalWrite(input, HIGH);

Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

0
Offline Offline
Shannon Member
****
Karma: 215
Posts: 12525
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This is a common issue reported here - input PINs float if not connected to some definite potential, which
is why pull-up or pull-down resistors (built-in or external) are required for interfacing to any mechanical
switch.
Logged

[ I won't respond to messages, use the forum please ]

Denmark
Offline Offline
God Member
*****
Karma: 15
Posts: 753
Please don't send questions as PM!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You are aware that you can do away without the Arduino ? There is no reason to have a microcontroller turn on an LED, the tilt switch can do that directly...

// Per.
Logged

Pages: [1]   Go Up
Jump to: