Skip to content

Commit 1bc5437

Browse files
Update README.md
1 parent 4e1fa4b commit 1bc5437

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

README.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,35 @@
22

33
An ESP32 library to get the moon phase angle and percentage of the moon that is illuminated.
44

5-
## Usage:
5+
#### Usage:
66

77
1. Download the latest release and unpack in the esp32 `libraries` folder.
88
2. Restart the Arduino IDE.
99

10-
Some examples are included.
10+
#### Example code:
11+
````c++
12+
#include <moonPhase.h>
13+
14+
moonPhase moonPhase; // include a MoonPhase instance
15+
16+
void setup() {
17+
Serial.begin(115200);
18+
Serial.println();
19+
Serial.println( "moonPhase simple example." );
20+
21+
moonData_t moon; // variable to receive the data
22+
23+
moon = moonPhase.getPhase(); // gets the current moon phase ( 1/1/1970 at 00:00:00 UTC )
24+
25+
Serial.print( "Moon phase angle: " );
26+
Serial.print( moon.angle ); // angle is a integer between 0-360
27+
Serial.println( " degrees." );
28+
Serial.print( "Moon surface lit: " );
29+
Serial.print( moon.percentLit * 100 ); // percentLit is a real between 0-1
30+
}
31+
32+
void loop() {
33+
// put your main code here, to run repeatedly:
34+
35+
}
36+
````

0 commit comments

Comments
 (0)