forked from Tatskaari/christmas_arduino_led_example
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Tatskaari/master
Moved code out of header file
- Loading branch information
Showing
2 changed files
with
28 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include <arduino.h> | ||
#include <string.h> | ||
#include "christmas.h" | ||
|
||
void setup() { | ||
initialise(); | ||
Serial.begin(9600); | ||
} | ||
|
||
void loop() { | ||
while(Serial.available() > 0){ | ||
String line = Serial.readStringUntil('\n'); | ||
if(strcmp(line.c_str(), "HO! HO! HO!") == 0){ | ||
ho_ho_ho(); | ||
} | ||
else if(strcmp(line.c_str(), "Merry Christmas!") == 0){ | ||
merry_christmas(); | ||
} | ||
else if(strcmp(line.c_str(), "Happy New Year!") == 0){ | ||
happy_new_year(); | ||
} | ||
} | ||
delay(1000); | ||
tick(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,16 @@ | ||
#include <arduino.h> | ||
#include <string.h> | ||
#ifndef __christmas_h_ | ||
#define __christmas_h_ | ||
|
||
#define HO_HO_HO "HO! HO! HO!" | ||
#define MERRY_CHRISTMAS "Merry Christmas!" | ||
#define HAPPY_NEW_YEAR "Happy New Year!" | ||
|
||
long last_tick_time = 0; | ||
|
||
void initialise(); | ||
void tick(); | ||
|
||
void ho_ho_ho(); | ||
void merry_christmas(); | ||
void happy_new_year(); | ||
|
||
void setup() { | ||
initialise(); | ||
Serial.begin(9600); | ||
|
||
} | ||
#endif //__christmas_h_ | ||
|
||
void loop() { | ||
while(Serial.available() > 0){ | ||
String line = Serial.readStringUntil('\n'); | ||
if(strcmp(line.c_str(), "HO! HO! HO!") == 0){ | ||
ho_ho_ho(); | ||
} | ||
else if(strcmp(line.c_str(), "Merry Christmas!") == 0){ | ||
merry_christmas(); | ||
} | ||
else if(strcmp(line.c_str(), "Happy New Year!") == 0){ | ||
happy_new_year(); | ||
} | ||
} | ||
delay(1000); | ||
tick(); | ||
} |