mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-30 16:24:09 +03:00
Committing individual examples instead of one .zip
This commit is contained in:
31
build/shared/dist/examples/digital IO/digital_read/digital_read.pde
vendored
Normal file
31
build/shared/dist/examples/digital IO/digital_read/digital_read.pde
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
/* Basic Digital Read
|
||||
* ------------------
|
||||
*
|
||||
* turns on and off a light emitting diode(LED) connected to digital
|
||||
* pin 13, when pressing a pushbutton attached to pin 7. It illustrates the
|
||||
* concept of Active-Low, which consists in connecting buttons using a
|
||||
* 1K to 10K pull-up resistor.
|
||||
*
|
||||
* Created 1 December 2005
|
||||
* copyleft 2005 DojoDave <http://www.0j0.org>
|
||||
* http://arduino.berlios.de
|
||||
*
|
||||
*/
|
||||
|
||||
int ledPin = 13; // choose the pin for the LED
|
||||
int inPin = 7; // choose the input pin (for a pushbutton)
|
||||
int val = 0; // variable for reading the pin status
|
||||
|
||||
void setup() {
|
||||
pinMode(ledPin, OUTPUT); // declare LED as output
|
||||
pinMode(inPin, INPUT); // declare pushbutton as input
|
||||
}
|
||||
|
||||
void loop(){
|
||||
val = digitalRead(inPin); // read input value
|
||||
if (val == HIGH) { // check if the input is HIGH (button released)
|
||||
digitalWrite(ledPin, LOW); // turn LED OFF
|
||||
} else {
|
||||
digitalWrite(ledPin, HIGH); // turn LED ON
|
||||
}
|
||||
}
|
24
build/shared/dist/examples/digital IO/digital_read_and_blink/digital_read_and_blink.pde
vendored
Normal file
24
build/shared/dist/examples/digital IO/digital_read_and_blink/digital_read_and_blink.pde
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
/* Blink when Digital Read
|
||||
* ------------------------
|
||||
*/
|
||||
|
||||
int ledPin = 13; // choose the pin for the LED
|
||||
int inPin = 7; // choose the input pin (for a pushbutton)
|
||||
int val = 0; // variable for reading the pin status
|
||||
|
||||
void setup() {
|
||||
pinMode(ledPin, OUTPUT); // declare LED as output
|
||||
pinMode(inPin, INPUT); // declare pushbutton as input
|
||||
}
|
||||
|
||||
void loop(){
|
||||
val = digitalRead(inPin); // read input value
|
||||
if (val == HIGH) { // check if the input is HIGH (button released)
|
||||
digitalWrite(ledPin, LOW); // turn LED OFF
|
||||
} else {
|
||||
digitalWrite(ledPin, HIGH); // blink the LED and go OFF
|
||||
delay(200);
|
||||
digitalWrite(ledPin, LOW);
|
||||
delay(1000);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user