odd problem - led turns on when hand is near
ok, took code digitalread reference entry , tried use turn on led using switch (just wanted try digitalread, know don't need use switch). got led connected pin 12 , switch connected pin 7. time led turns on when switch on , hand nearby (not touching, nearby, regardless if i'm grounded wriststrap or not). circuit switch doesn't have completed; can have 1 wire in pin 7 , other in air not touching anything; put hand nearby , led turns on.
its basic knowledge known electronics savvy people, clueless up. btw, have tried setting circuit/s ton of different ways (common ground, seperate ciruits, in series no ground, in series common ground, pull resistor, pull down resistor, etc.); weren't correct gave me same result , rest gave me none. below code.
its basic knowledge known electronics savvy people, clueless up. btw, have tried setting circuit/s ton of different ways (common ground, seperate ciruits, in series no ground, in series common ground, pull resistor, pull down resistor, etc.); weren't correct gave me same result , rest gave me none. below code.
code: [select]
int ledpin = 12; // led connected digital pin 12
int inpin = 7; // switch connected digital pin 7
int val = 0; // variable store read value
void setup()
{
pinmode(ledpin, output); // sets digital pin 12 output
pinmode(inpin, input); // sets digital pin 7 input
}
void loop()
{
val = digitalread(inpin); // read input pin
digitalwrite(ledpin, val); // sets led switch's value
}
i'd guess problem in circuit. check out photo button example: http://arduino.cc/en/tutorial/button
Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > odd problem - led turns on when hand is near
arduino
Comments
Post a Comment