File: p15_HackingButtons.ino

package info (click to toggle)
arduino 2%3A1.0.5%2Bdfsg2-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 40,280 kB
  • ctags: 18,385
  • sloc: java: 57,238; cpp: 23,031; ansic: 13,695; makefile: 2,315; xml: 468; perl: 201; sh: 156; python: 62
file content (37 lines) | stat: -rw-r--r-- 848 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
  Arduino Starter Kit example
 Project 15  - Hacking Buttons
 
 This sketch is written to accompany Project 15 in the
 Arduino Starter Kit
 
 Parts required:
 batery powered component
 220 ohm resistor
 4N35 optocoupler
 
 Created 18 September 2012
 by Scott Fitzgerald
 
 http://arduino.cc/starterKit
 
 This example code is part of the public domain 
 */

const int optoPin = 2; // the pin the optocoupler is connected to

void setup(){
  // make the pin with the optocoupler an output 
  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 
}