-
Notifications
You must be signed in to change notification settings - Fork 2
/
Grove_LED.ino
36 lines (31 loc) · 836 Bytes
/
Grove_LED.ino
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
// Demo for Grove - Starter V2.0
// Author: Loovee 2013-3-10
// Pulses the Grove - LED with a "breathing" effect.
// Connect the Grove - LED to the socket marked D3
// Defines the pin to which the LED is connected.
// Any pin that supports PWM can also be used:
// 3, 5, 6, 9, 10, 11
const int pinLed = 3;
// Define the delay for the "breathing" effect; change this
// to a smaller value for a faster effect, larger for slower.
const int BREATH_DELAY = 5; // milliseconds
void setup()
{
// Configure the LED's pin for output signals.
pinMode(pinLed, OUTPUT);
}
void loop()
{
for(int i=0; i<256; i++)
{
analogWrite(pinLed, i);
delay(BREATH_DELAY);
}
delay(100);
for(int i=254; i>=0; i--)
{
analogWrite(pinLed, i);
delay(BREATH_DELAY);
}
delay(500);
}