Debian Codegraph @

examples/10.StarterKit_BasicKit/p15_HackingButtons/p15_HackingButtons.ino

raw
1 /*
2 Arduino Starter Kit example
3 Project 15 - Hacking Buttons
4
5 This sketch is written to accompany Project 15 in the Arduino Starter Kit
6
7 Parts required:
8 - battery powered component
9 - 220 ohm resistor
10 - 4N35 optocoupler
11
12 created 18 Sep 2012
13 by Scott Fitzgerald
14
15 https://store.arduino.cc/genuino-starter-kit
16
17 This example code is part of the public domain.
18 */
19
20 const int optoPin = 2; // the pin the optocoupler is connected to
21
22 void setup() {
23 // make the pin with the optocoupler an output
24 pinMode(optoPin, OUTPUT);
25 }
26
27 void loop() {
28 digitalWrite(optoPin, HIGH); // pull pin 2 HIGH, activating the optocoupler
29
30 delay(15); // give the optocoupler a moment to activate
31
32 digitalWrite(optoPin, LOW); // pull pin 2 low until you're ready to activate again
33 delay(21000); // wait for 21 seconds
34 }