forked from microbuilder/LPC810_CodeBase
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample03_Button.c
More file actions
88 lines (66 loc) · 2.19 KB
/
example03_Button.c
File metadata and controls
88 lines (66 loc) · 2.19 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include "sketch_ino.h"
/*** LPC810 Arduino compatible library example ***/
/*
Button
Turns on and off a light emitting diode(LED) connected to digital
pin 2, when pressing a pushbutton attached to pin 1.
The circuit:
* LED attached from pin 2 to VCC
* pushbutton attached to pin 1 from GND
* 10K resistor attached to pin 2 to VCC
* Note: On the LPC810 Minikit there is already an LED on the board
attached to pin 2.
reworked for LPC810 2014 ChrisMicro
created 2005
by DojoDave <http://www.0j0.org>
modified 30 Aug 2011
by Tom Igoe
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/Button
*/
// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 1; // the number of the pushbutton pin
const int ledPin = 2; // the number of the LED pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
void loop(){
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED off:
digitalWrite(ledPin, HIGH);
}
else {
// turn LED on:
digitalWrite(ledPin, LOW);
}
}
/*
LPC800 Pining ( Arduino pin numbering )
=======================================
________
| U |
reset -| |- digital 0 / analog in A0 / RX
TX / digital 4 -| LPC |- GND
digital 3 -| 810 |- +3.3V
digital 2 -| |- digital 1 / analog in A1
|_______|
Mini Kit Board ( http://www.lpcware.com/lpc800-mini-kit )
=========================================================
________
| U |
reset switch -| |- RX
TX -| LPC |- GND
-| 810 |- +3.3V
test led -| |- ISP switch
|_______|
*/