Stap 3: Program de Arduino
De enige code u moet is het digitale schrijven knipperende LED uit de bibliotheek.Tip: Als u wilt testen van ingangen, het is een goed idee om het gebruik van LED's.
1) Kopieer en plak deze code in het programma van Arduino:
(Code van www.arduino.cc)
/* Blink Turns on an LED on for one second, then off for one second, repeatedly. The circuit: * LED connected from digital pin 13 to ground. * Note: On most Arduino boards, there is already an LED on the board connected to pin 13, so you don't need any extra components for this example. Created 1 June 2005 By David Cuartielleshttp://arduino.cc/en/Tutorial/Blink based on an orginal by H. Barragan for the Wiring i/o board */
int ledPin = 13; // LED connected to digital pin 13
// The setup() method runs once, when the sketch starts
voidsetup() { // initialize the digital pin as an output:pinMode(ledPin, OUTPUT); }
// the loop() method runs over and over again,// as long as the Arduino has power
voidloop() { digitalWrite(ledPin, HIGH); // set the LED ondelay(1000); // wait for a seconddigitalWrite(ledPin, LOW); // set the LED offdelay(1000); // wait for a second } 2)Plug in your Arduino and transfer the code 3)Place an LED on pin 13 if you are using the board or on the right input pin from the Atmega chip if you are using the breadboard setup. 4)Test it! if it works, you are good to go. Now, here is the great thing about controlling the pulse of the circuit with the Arduino. You can modify the delay time so that you have slower or faster pulses, and with this practically control your whole experiment. If you wish to add other things like lights, sound, or anything else you just go to the code and modify it. I suggest you plug the Arduino from an independent power source (it needs to be 5V).