When my arduino arrived i tested 'blinky' then i edited it a little to flash SOS in morse which got me excited to get the servos and stuff...
Alas I wanted to do something more advanced today but I will have to wait for a delivery to arrive since maplin are overpriced af i only have a switch and some basic components from a few years ago ( resistors, diodes, capacitors.
I was told that i should not short an I/O pin and ground or an I/O pin and an I/O pin , thats how I would imagine using a switch as an input, do i just need a resistor? About what size? Do i need to use a different pin entirely?
Sorry for this, i just need to make sure of what im doing.
It's OK to connect an INPUT pin to Ground or +5V, just not an OUTPUT pin. When the processor is reset all of the pins default to INPUT.
An easy way to use a switch is the set the pin to pinMode(pin, INPUT_PULLUP) and connect the switch between the pin and Ground. The internal pull-up resistor will cause the pin to read HIGH when not connected to Ground and LOW when connected to Ground. Switch Open==HIGH. Switch Closed==LOW.
Some people seem to be averse to having HIGH mean Open and LOW mean Closed so they set the pinMode to INPUT and add an external pull-down resistor (1K to 10K resistor between pin and Ground). Then they connect a switch between the pin and +5V. This makes HIGH mean Closed and LOW mean Open but it requires an external resistor.
If you don't have a pull-up or pull-down resistor you will get random results from your input pin when it is not connected to something (like when the switch is open). This is called a 'floating' input.
Lewissunn:
When my arduino arrived i tested 'blinky' then i edited it a little to flash SOS in morse which got me excited to get the servos and stuff...
Alas I wanted to do something more advanced today but I will have to wait for a delivery to arrive since maplin are overpriced af i only have a switch and some basic components from a few years ago ( resistors, diodes, capacitors.
I was told that i should not short an I/O pin and ground or an I/O pin and an I/O pin , thats how I would imagine using a switch as an input, do i just need a resistor? About what size? Do i need to use a different pin entirely?
Sorry for this, i just need to make sure of what im doing.
for switch detecting, you would be very safe with a 1k resistor.
don't be sorry ! my mother used to say that asking stupid questions avoids making stupid mistakes !
if you have any transistors, you could still have some fun.
an old battery toothbrush or battery type straight blade razors with the tiny motors.
blink, fade, LED's
older electronics used to have parts you could salvage, motors, things like that.
old CD drives or floppy drives.....
Hutkikz:
Nick Gammon's switch tutorial
I am half temped to count bounced of a switch. his scope output shows a lot of spikes in very short order.
good link BTW.
dave-in-nj:
for switch detecting, you would be very safe with a 1k resistor.
don't be sorry ! my mother used to say that asking stupid questions avoids making stupid mistakes !
if you have any transistors, you could still have some fun.
an old battery toothbrush or battery type straight blade razors with the tiny motors.
blink, fade, LED's
older electronics used to have parts you could salvage, motors, things like that.
old CD drives or floppy drives.....
Thanks
Ive got some DC motors but i think i would need to use a relay to for them with the amp limit on the arduino and im currently really short on components ( a couple months ago i might have blown all my LED's ) Im currently ordering components online since all the shops in the UK are really overpriced which completely ruined my mood. £9 for 80 LED's?? ? ? 10X markup, i could theoretically buy another arduino for 180 LED's....
Thanks everyone though. This community seems great.
Lewissunn:
...got some DC motors but i think i would need to use a relay to for them...
When you go to hooking up your relay and/or motor, I recommend being careful how you connect them to the Arduino. Some relay boards have the necessary circuitry to drive directly from an Arduino pin, but a bare relay does not. Here is an article I like: Using Transistor as a Switch | ermicroblog