Argentina
Offline
Full Member
Karma: 4
Posts: 158
|
 |
« on: August 14, 2012, 10:53:51 pm » |
Actually working on this: and migrated the sketch to a Mini Pro this night. Wanted to know IF It is a good practice to use an available pin to feed signal for a pull up switch. Do you know what I mean? For example, I have pin 8 and 9 free, and would like to use one of them to supply trigger switch.
|
|
|
|
|
Logged
|
|
|
|
|
SE USA
Offline
Faraday Member
Karma: 35
Posts: 3650
@ssh0le
|
 |
« Reply #1 on: August 15, 2012, 12:00:02 am » |
the avr supports internal pullups so you dont have to use extra pins
set your pinMode to input, and then digital write high to the same pin in the setup function, you now have a input pin that is pulled high by the chip
|
|
|
|
|
Logged
|
http://arduino.cc/forum/index.php?action=unread;boards=2,3,4,5,67,6,7,8,9,10,11,66,12,13,15,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,86,87,89,1;ALL
|
|
|
|
Argentina
Offline
Full Member
Karma: 4
Posts: 158
|
 |
« Reply #2 on: August 15, 2012, 12:21:58 pm » |
I think I did not explained my self. Just take a look at this circuit:  I was talking about using a pin 7 in high state to feed the switch instead of connect the 5v.
|
|
|
|
|
Logged
|
|
|
|
|
Wisconsin
Offline
God Member
Karma: 4
Posts: 994
I LOVE THIS STUFF!!!!
|
 |
« Reply #3 on: August 15, 2012, 12:35:55 pm » |
I think I get what you are saying.
Instead of having a button be the switch, you would set one pin to an input, and one pin to and output and then just connect them. You would control the "switch" but using a digitalWrite High or Low command for the output pin and then just use digitalRead elsewhere in your code to detect whether its on or not.
Right?
|
|
|
|
|
Logged
|
Accelerate to 88 miles per hour.
|
|
|
|
Argentina
Offline
Full Member
Karma: 4
Posts: 158
|
 |
« Reply #4 on: August 15, 2012, 12:44:10 pm » |
Right. My problem is that I will be using an unregulated power supply to feed the arduino mini pro, so I don't have a 5v power source to feed the switch. So I was thinking in re-use an available pin to do that work.
|
|
|
|
|
Logged
|
|
|
|
|
Wisconsin
Offline
God Member
Karma: 4
Posts: 994
I LOVE THIS STUFF!!!!
|
 |
« Reply #5 on: August 15, 2012, 12:48:33 pm » |
Oh, is this whole thing operating at 3.3V? If you have enough power to send a HIGH signal to the microcontroller, then you can still use the button by feeding it 3.3V.
What the button does is just make a circuit. When its pressed, it completes the circuit. Since the output is connected to the arduino, and if the whole thing is running at 3.3V and is using 3.3V logic, then getting a t 3.3V from the button will still send the HIGH signal.
What voltage are you going to be using? Is this a 3.3v pro mini or a 5v pro mini.
|
|
|
|
|
Logged
|
Accelerate to 88 miles per hour.
|
|
|
|
Argentina
Offline
Full Member
Karma: 0
Posts: 248
|
 |
« Reply #6 on: August 15, 2012, 12:51:16 pm » |
No need to use another pin to "feed signal". You can activate the internal pull up, so you can forget about that extra resistor you are using. You can achieve this by using: pinMode(2, INPUT); digitalWrite(2, HIGH);
More about it here: http://www.arduino.cc/en/Tutorial/DigitalPinsby using the internal pullup, you just use the switch to give a temporary connection to ground.
|
|
|
|
|
Logged
|
|
|
|
|
Argentina
Offline
Full Member
Karma: 4
Posts: 158
|
 |
« Reply #7 on: August 15, 2012, 12:56:34 pm » |
Wow! Thanks, good to know about that. Gracias Martin, yo tambien soy de Argentina. PD: Encontre este ejemplo despues de investigar: http://www.arduino.cc/en/Tutorial/InputPullupSerial
|
|
|
|
« Last Edit: August 15, 2012, 01:15:57 pm by the-rebel-agent »
|
Logged
|
|
|
|
|
SE USA
Offline
Faraday Member
Karma: 35
Posts: 3650
@ssh0le
|
 |
« Reply #8 on: August 15, 2012, 10:29:13 pm » |
arg! thats what I said, use the internal pullup
thats it, no candy for you!
(kidding, you can have some candy)
|
|
|
|
|
Logged
|
http://arduino.cc/forum/index.php?action=unread;boards=2,3,4,5,67,6,7,8,9,10,11,66,12,13,15,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,86,87,89,1;ALL
|
|
|
|
Argentina
Offline
Full Member
Karma: 4
Posts: 158
|
 |
« Reply #9 on: August 15, 2012, 11:31:15 pm » |
Sorry I did not get it from the very fist time. Reading that tutorial found out about the INPUTPULLUP mode, that saves you 1 line of code BTW.
|
|
|
|
|
Logged
|
|
|
|
|
SE USA
Offline
Faraday Member
Karma: 35
Posts: 3650
@ssh0le
|
 |
« Reply #10 on: August 16, 2012, 12:09:32 am » |
it does now, think they introduced that with 1.0 while breaking compatibility with 5+ years of libraries (give n take right?)
|
|
|
|
|
Logged
|
http://arduino.cc/forum/index.php?action=unread;boards=2,3,4,5,67,6,7,8,9,10,11,66,12,13,15,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,86,87,89,1;ALL
|
|
|
|
Argentina
Offline
Full Member
Karma: 4
Posts: 158
|
 |
« Reply #11 on: August 16, 2012, 01:05:42 am » |
Added for 1.0.1. Just tested and worked out like a charm. Right now testing an Ethernet shield r3. Connected it to the laser gun project and every time the server detects an incoming connection fires the laser gun. Very funny.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
God Member
Karma: 6
Posts: 954
Arduino rocks
|
 |
« Reply #12 on: August 16, 2012, 10:14:33 am » |
very cool!.. I too am working on code for a blaster (blasterOSv1.0) similar to yours.. I have it doing a: 'power on/boot sound' slider switch for manual fire or auto fire RGB led so I can pick my color for fire type(s).. my last step was to add a motor.. so I could spin the barrel like a gatling gun.. but I havent been able to find a small motor with enough torque and speed to work.. http://www.youtube.com/v/4RuLUTsuSpg?version=3&hl=en_US&rel=0
|
|
|
|
« Last Edit: August 16, 2012, 10:34:58 am by xl97 »
|
Logged
|
|
|
|
|
Argentina
Offline
Full Member
Karma: 4
Posts: 158
|
 |
« Reply #13 on: August 16, 2012, 12:11:35 pm » |
Very cool blaster idea. Love the automatic firing option. Not applicable to V Visitor laser gun, but could be implemented for other ones. Will add that feature to my software. Implemented the INPUT_PULLUP pin method and combined it with the Ethernet shield.   Now I am activating the trigger over the Internet from my work and the laser gun is resting at my dinner table at home. Cool right?
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
God Member
Karma: 6
Posts: 954
Arduino rocks
|
 |
« Reply #14 on: August 16, 2012, 12:37:17 pm » |
VERY cool! I have YET to play with any Ethernet stuff or my RFID stuff yet!! just worked on the Arduino/Waveshield merge.. and some initial code for now.. love your project thought.. I always read your posts now that I know you belong to www.therpf.com .. lol
|
|
|
|
|
Logged
|
|
|
|
|
|