Skip to content

Commit a66de63

Browse files
committed
examples: Added examples fro GPIO functions.
Signed-off-by: MDin <[email protected]>
1 parent aba874a commit a66de63

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

examples/blink/blink.ino

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include "Arduino.h"
2+
int val = 0;
3+
void setup()
4+
{
5+
pinMode(LED_BUILTIN, OUTPUT);
6+
pinMode(23, OUTPUT);
7+
}
8+
9+
void loop()
10+
{
11+
digitalWrite(LED_BUILTIN, 0);
12+
digitalWrite(23, val);
13+
delay(1000);
14+
digitalWrite(LED_BUILTIN, 1);
15+
digitalWrite(23, 1);
16+
delay(1000);
17+
}

examples/button/button.ino

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include "Arduino.h"
2+
int ledPin = 22; // LED connected to digital pin 13
3+
int inPin = 25; // pushbutton connected to digital pin 7
4+
int val; // variable to store the read value
5+
6+
void setup() {
7+
pinMode(ledPin, OUTPUT); // sets the digital pin 13 as output
8+
pinMode(inPin, INPUT_PULLDOWN); // sets the digital pin 7 as input
9+
}
10+
11+
void loop() {
12+
val = digitalRead(inPin); // read the input pin
13+
digitalWrite(ledPin, val); // sets the LED to the button's value
14+
}
15+

0 commit comments

Comments
 (0)