Let's Make Robots!

pinmode(HIGH and LOW)

dear reader, (xD)

i am just reading how to program an adriuno. but i dont understand the high and low part of putting to the pins..

from what i understand the only pherpase is to avoid noises??

 

is this correct?

thnxx nick janse

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

is rather to the point about what pinMode() does.

http://arduino.cc/en/Reference/PinMode

To reiterate, pinMode(pin,mode); sets the given pin to the given mode either input or output.

pinMode() does not accept HIGH or LOW as an arguement.

oh yes i understand, i made a mistake ...

i actuly mean is why should u put a pin to high?

is it because there is no elektriciti on the pin before, and therefor set the pin to high it wil get its elektriciti?

i dont understand i think... please help me out here xD

 

You use the digitalWrite(pin, HIGH/LOW) basically as a switch.

Take an LED for example:
The LED is hooked up to say, pin 3. You want to be able to turn the LED on or off, so your Pinmode will be output.
Then what you do is set your switch to on, so the pin goes HIGH.
When you want it turned off again, you set it to low.

When using the pin as an input(Pinmode(pin, INPUT), for example with a push button, you want the pin to detect if it is high or low.
So, when your button is pushed, thus letting through current, your program should have a statement that reads the pin instead of writes to it.

If you are a beginner, I highly recommend you to follow some tutorials.
I used the tutorials from oomlout, which you can find here: http://www.oomlout.com/a/products/ardx/
They are really easy, don't need a lot of parts, and they are very low profile in learningcurve. 
Using tutorials like these you'll see that questions like this one are easily answered.
I don't mind answering questions, but the tutorials explain everything you need to know, and save you time in waiting for an answer. 

prettymuch yeah, if you are setting the pin to high yourself like when u make an led light up,
then yeah doing that will make power go to that pin, and setting it to 'low' will cut the power off.

if you are using it as an input however, like when u have a sensor attached to it, then it is up to
the chip to determine how much power sets the pins high and low so you will have to set a
treshold value in your program.