mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-30 16:24:09 +03:00
Updating examples.
This commit is contained in:
25
build/shared/dist/examples/Digital/Blink/Blink.pde
vendored
Normal file
25
build/shared/dist/examples/Digital/Blink/Blink.pde
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Blink
|
||||
*
|
||||
* The basic Arduino example. Turns on an LED on for one second,
|
||||
* then off for one second, and so on... We use pin 13 because,
|
||||
* depending on your Arduino board, it has either a built-in LED
|
||||
* or a built-in resistor so that you need only an LED.
|
||||
*
|
||||
* http://www.arduino.cc/en/Tutorial/Blink
|
||||
*/
|
||||
|
||||
int ledPin = 13; // LED connected to digital pin 13
|
||||
|
||||
void setup() // run once, when the sketch starts
|
||||
{
|
||||
pinMode(ledPin, OUTPUT); // sets the digital pin as output
|
||||
}
|
||||
|
||||
void loop() // run over and over again
|
||||
{
|
||||
digitalWrite(ledPin, HIGH); // sets the LED on
|
||||
delay(1000); // waits for a second
|
||||
digitalWrite(ledPin, LOW); // sets the LED off
|
||||
delay(1000); // waits for a second
|
||||
}
|
27
build/shared/dist/examples/Digital/Button/Button.pde
vendored
Normal file
27
build/shared/dist/examples/Digital/Button/Button.pde
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Button
|
||||
* by DojoDave <http://www.0j0.org>
|
||||
*
|
||||
* Turns on and off a light emitting diode(LED) connected to digital
|
||||
* pin 13, when pressing a pushbutton attached to pin 7.
|
||||
*
|
||||
* http://www.arduino.cc/en/Tutorial/Button
|
||||
*/
|
||||
|
||||
int ledPin = 13; // choose the pin for the LED
|
||||
int inputPin = 2; // 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(inputPin, INPUT); // declare pushbutton as input
|
||||
}
|
||||
|
||||
void loop(){
|
||||
val = digitalRead(inputPin); // read input value
|
||||
if (val == HIGH) { // check if the input is HIGH
|
||||
digitalWrite(ledPin, LOW); // turn LED OFF
|
||||
} else {
|
||||
digitalWrite(ledPin, HIGH); // turn LED ON
|
||||
}
|
||||
}
|
37
build/shared/dist/examples/Digital/Loop/Loop.pde
vendored
Normal file
37
build/shared/dist/examples/Digital/Loop/Loop.pde
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Loop
|
||||
* by David A. Mellis
|
||||
*
|
||||
* Lights multiple LEDs in sequence, then in reverse. Demonstrates
|
||||
* the use of a for() loop and arrays.
|
||||
*
|
||||
* http://www.arduino.cc/en/Tutorial/Loop
|
||||
*/
|
||||
|
||||
int timer = 100; // The higher the number, the slower the timing.
|
||||
int pins[] = { 2, 3, 4, 5, 6, 7 }; // an array of pin numbers
|
||||
int num_pins = 6; // the number of pins (i.e. the length of the array)
|
||||
|
||||
void setup()
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < num_pins; i++) // the array elements are numbered from 0 to num_pins - 1
|
||||
pinMode(pins[i], OUTPUT); // set each pin as an output
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < num_pins; i++) { // loop through each pin...
|
||||
digitalWrite(pins[i], HIGH); // turning it on,
|
||||
delay(timer); // pausing,
|
||||
digitalWrite(pins[i], LOW); // and turning it off.
|
||||
}
|
||||
for (i = num_pins - 1; i >= 0; i--) {
|
||||
digitalWrite(i, HIGH);
|
||||
delay(timer);
|
||||
digitalWrite(i, LOW);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user