Go Down

Topic: using digital pins and "pull up" and "pull down" resisters (Read 1 time) previous topic - next topic

dmac257

I am new to my Arduino Uno and am a little fuzzy on the pin voltages and use of "pull up" and "pull down" resisters.  I might be thinking wrong but what I am trying to do is attach a couple of switches to the digital pins and modify the "blink" sketch to check the switches (input) and based on which switches are closed select a value to use in the delay(XXXX) portion of the loop.  It is my understanding that during the delay the Arduino does nothing but is it safe to change the switches under power?  I will be using a DIP switch to select 4 different pins either HIGH or LOW and using the resulting binary combinations to give me 16 selectable values for the delay().  The delay will be from 2 to 32 MINUTES so it will be unlikely to be in middle of switching when board checks the switch settings, but what I am worried about it do I need to remove power/hold reset button when changing the DIP positions?

Am I correct in understanding that the position of the resister determines if pull-down or pull-up and it can be either with the same components.  I don't know how to make image here but if:
5V->N/O switch->pin2 set as input->10K resister->GND --- resister here is pull down
5V->10K resister->pin2 set as input->N/O switch->GND --- resister here is pull up
only difference is if check for HIGH or LOW on pin2 correct so far??
and since there is no real difference between a closed DIP switch and a N/O switch with a finger pushing on it continuously or open DIP switch and a N/O switch released, IF is safe to swich under power I can test the sketch with 4 pushbuttons and short delay values first .  Just don't want to hurt the board if not safe to do this under power.

Thansk,
dmac257

RuggedCircuits

Quote
what I am worried about it do I need to remove power/hold reset button when changing the DIP positions?


Nothing to be worried about. You can change DIP switch positions at any time.

Quote
V->10K resister->pin2 set as input->N/O switch->GND --- resister here is pull up


This is the most common, mostly because the Arduino microcontroller has built-in pullup resistors that can be enabled so you don't even need the external resistor. Make sure "V" in your hookup is 5V and not some arbitrary voltage.

--
The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, speaker, microphone, light sensor, potentiometer, pushbuttons

dmac257

Quote
V->10K resister->pin2 set as input->N/O switch->GND --- resister here is pull up

This is the most common, mostly because the Arduino microcontroller has built-in pullup resistors that can be enabled so you don't even need the external resistor. Make sure "V" in your hookup is 5V and not some arbitrary voltage.


In my origional question I had the 5V and will be using the 5V socket on the UNO as source.  How do you "enable" the built-in pullup resistors inside the 328?  For now I will use the 10K resister but would be nice not to have the extra components.

dmac257

RuggedCircuits

The built-in pullup resistors are enabled by configuring pins as inputs then writing them high as if they were outputs:

Code: [Select]

pinMode(10, INPUT); // Or whatever pin...doesn't have to be 10...
digitalWrite(10, HIGH);  // Pin 10 now has a pullup resistor enabled


--
The Aussie Shield: breakout all 28 pins to quick-connect terminals

cmpenoob

not to thread hijack, but I have a question about pull down resistance. What are the drawbacks/dangers to having a low pull down, say 1k? I don't think I can use pull ups 'cause my switches have diodes in front of them... mm while I'm at it, how much resistance could a poor solder joint add :)

hope you're enjoying the arduino so far dmac!

Go Up