11.07.2015 Views

ARDX-experimenters-g.. - Oomlout

ARDX-experimenters-g.. - Oomlout

ARDX-experimenters-g.. - Oomlout

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Code (no need to type everything in just)File > Sketchbook > Examples > Digital > Blink(example from the great arduino.cc site check it out for other great ideas)CIRC-11/** Blink** The basic Arduino example. Turns on an LED on for one second,* then off for one second, and so on... We use pin 13 because,* depending on your Arduino board, it has either a built-in LED* or a built-in resistor so that you need only an LED.** http://www.arduino.cc/en/Tutorial/Blink*/int ledPin = 2; // *********** CHANGE TO PIN 2 ************void setup()// run once, when the sketch starts{pinMode(ledPin, OUTPUT); // sets the digital pin as output}void loop(){digitalWrite(ledPin, HIGH);delay(1000);digitalWrite(ledPin, LOW);delay(1000);}// run over and over again// sets the LED on// waits for a second// sets the LED off// waits for a secondNot Working? (3 things to try)Nothing HappensNo Clicking SoundThe example code uses pin 13The transistor or coil portion ofand we have the relaythe circuit isn't quite working.connected to pin 2. Make sureCheck the transistor is pluggedyou made this change in thein the right way.code.Not Quite WorkingThe included relays aredesigned to be soldered ratherthan used in a breadboard. Assuch you may need to press itin to ensure it works. (and itmay pop out occasionally)Making it BetterControlling a MotorIn CIRC-03 we controlled a motor using a transistor.However if you want to control a larger motor a relay is agood option. To do this simply remove the red LED, andconnect the motor in its place (remember to bypass the560 Ohm resistor)Controlling Motor DirectionA bit of a complicated improvement to finish. To controlthe direction of spin of a DC motor we must be able toreverse the direction of current flow through it. To do thismanually we reverse the leads. To do it electrically werequire something called an h-bridge. This can be doneusing a DPDT relay to control the motor's direction, wireup the following circuit.DPDT RelayH-BridgeToyMotorresistor (2.2kohm)(red-red-red)NOIt looks complicated but can be accomplished using onlya few extra wires. Give it a try.NCcomCollectorcoilBase+5 voltsgnd(ground) (-)Arduinopin 2TransistorP2N2222AGEmitterDiode(flyback)More, More, More:More details, where to buy more parts, where to ask more questions.http://tinyurl.com/cfagqn29

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!