Wiring Forum
http://wiring.org.co/cgi-bin/yabb/YaBB.pl
Programming Questions & Help >> Syntax >> pinMode question
http://wiring.org.co/cgi-bin/yabb/YaBB.pl?num=1262202348

Message started by Tilade on 12/30/09 at 19:45:48

Title: pinMode question
Post by Tilade on 12/30/09 at 19:45:48
I'm rather new to the language, but not coding in general.  I did a test last night where if an analog input reached a certain level, it triggered a digital pin high.  The only problem was that the output was lousy and only outputting about 100 mV from a 9V power supply. 

This morning I noticed that I forgot to define the digital pin as an output with the pinMode command.  Of course this was before leaving for work.  I'm anxious to know, would not defining a pinMode, but still instructing it to output at a certain time cause this behavior?  I would suggest that if this is a problem, to have the program throw an error when compiling if this is the case.

Thanks!

Title: Re: pinMode question
Post by barragan on 12/31/09 at 00:47:10
hi Tilade, I understand your concern, actually it is not a bug, it is the normal pin behavior when doing it as you did, of course it doesn't work as expected, but from the syntax's point of view it is not wrong, so the compiler would pass it. Detecting and reporting this as an error involves a very smart interpreter to do this kind of semantic validation.

Title: Re: pinMode question
Post by Tilade on 12/31/09 at 06:49:05
Thanks for the reply barragan.  I recompiled the code with the pinMode defined and it works perfectly.  It's fun learning the little runtime problems that I create and how to prevent them.  Thanks for the help!

Title: Re: pinMode question
Post by barragan on 12/31/09 at 17:49:33
no problem :)

Wiring Forum » Powered by YaBB 2.5 AE!
YaBB Forum Software © 2000-2010. All Rights Reserved.