Pages: [1]   Go Down
Author Topic: Basic Touch Sensor / Switch program  (Read 835 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 11
Arduino Noob
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello!

I'm totally new to Arduino -- I just bought my first kit last week.  Please bear with me. 


I'm trying to create an extremely simple circuit that will run current through a wire, and detect if and when the circuit is broken.  This is probably the easiest project you guys have ever heard of, but right now, I'm having a hard time figuring out how to accomplish it.  Right now, I'm thinking out treating the wire like its a switch, and simply checking to make sure that its digital value remains constant at 1, and when it changes to 0, continue with the program. 

My main issue is figuring out where I should attach the wires and how I should connect them to the board -- I have an Arduino Uno and a fully assembled Sparkfun "Protoboard", but I cant figure out what else I would need to make the circuit work and where I should attach it. 

I would greatly appreciate any insight into what other electronics I need to attach to make this work, and also where I should place then, and I how I would acknowledge this in the code.  I'm used to systems like the Handyboard and CBC where we dont have to do a lot of this stuff -- so hopefully you guys can introduce me into the platform and kickstart my Arduino career.

Thanks!   smiley
Logged

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

You could read it as an analog value, use a common ground. Don't try measuring voltages coming out of the wallsocket though, stay within limits of the input range of your board.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
Arduino Noob
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm going to be powering this off a 9v battery, so no problem with voltages.

So I should just connect the wire to a 3v and a gnd and read the value as an analog?
Logged

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

Errr, NO!.. what's your setup? Details would help, if you're totally new to electronics you might wanna read up on that too.
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 437
Posts: 23718
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Take a simple approach.

Define a pin as an input, with pullup resister enabled.
pinMode (pinx, INPUT);
digitalWrite(pinX, HIGH);

connect the pin to ground with your wire.

Then read it, when it goes high, the ground connection has been broken:

voild loop(){
pinX_state = digitalRead(pinX);
if (pinX_state == 0)
{
// do something, like turn on an LED
}

}  // end loop
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 11
Arduino Noob
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Questions for CrossRoads:

1.  What kind of pullup resistor should I purchase?

2.  Exactly which pins on the Ardunio Uno / SparkFun Protoboard should I attach the wire too?  Where should I place the LED?  How should I wire it?  I don't really understand. 

I'm a total noob when it comes to this sort of stuff (I've mainly been working with HandyBoard / CBC, where all of the sensors and motors fit nicely into predefined slots and you don't have to worry about anything on the electronics side). 

Thanks!
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 437
Posts: 23718
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

1. None. Use the internal pullup:
pinMode (pinx, INPUT);
digitalWrite(pinX, HIGH);  << this connects the internal pullup for pinX

2.  Hmm. Okay, go back and do some of the Learning tutorials. Specifically Blink & Button.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

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

LadyAda has great step by step tutorials
Logged

Pages: [1]   Go Up
Jump to: