source: arduino-1-6-7/trunk/fuentes/arduino-ide-amd64/examples/10.StarterKit_BasicKit/p15_HackingButtons/p15_HackingButtons.ino @ 4837

Last change on this file since 4837 was 4837, checked in by daduve, 2 years ago

Adding new version

File size: 818 bytes
Line 
1/*
2  Arduino Starter Kit example
3 Project 15  - Hacking Buttons
4
5 This sketch is written to accompany Project 15 in the
6 Arduino Starter Kit
7
8 Parts required:
9 batery powered component
10 220 ohm resistor
11 4N35 optocoupler
12
13 Created 18 September 2012
14 by Scott Fitzgerald
15
16 http://www.arduino.cc/starterKit
17
18 This example code is part of the public domain
19 */
20
21const int optoPin = 2; // the pin the optocoupler is connected to
22
23void setup() {
24  // make the pin with the optocoupler an output
25  pinMode(optoPin, OUTPUT);
26}
27
28void loop() {
29  digitalWrite(optoPin, HIGH);  // pull pin 2 HIGH, activating the optocoupler
30
31  delay(15); // give the optocoupler a moment to activate
32
33  digitalWrite(optoPin, LOW);  // pull pin 2 low until you're ready to activate again
34  delay(21000);                // wait for 21 seconds
35}
36
37
Note: See TracBrowser for help on using the repository browser.