1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-12-12 23:08:52 +01:00
Arduino/build/shared/examples/10.StarterKit/p15_HackingButtons/p15_HackingButtons.ino

38 lines
814 B
Arduino
Raw Normal View History

2012-10-12 19:23:48 +02:00
/*
Arduino Starter Kit example
Project 15 - Hacking Buttons
2012-10-12 19:23:48 +02:00
This sketch is written to accompany Project 15 in the
Arduino Starter Kit
2012-10-12 19:23:48 +02:00
Parts required:
batery powered component
220 ohm resistor
4N35 optocoupler
2012-10-12 19:23:48 +02:00
Created 18 September 2012
by Scott Fitzgerald
2012-10-12 19:23:48 +02:00
http://arduino.cc/starterKit
This example code is part of the public domain
2012-10-12 19:23:48 +02:00
*/
const int optoPin = 2; // the pin the optocoupler is connected to
void setup() {
// make the pin with the optocoupler an output
2012-10-12 19:23:48 +02:00
pinMode(optoPin, OUTPUT);
}
void loop() {
digitalWrite(optoPin, HIGH); // pull pin 2 HIGH, activating the optocoupler
delay(15); // give the optocoupler a moment to activate
digitalWrite(optoPin, LOW); // pull pin 2 low until you're ready to activate again
delay(21000); // wait for 21 seconds
2012-10-12 19:23:48 +02:00
}