Last active
November 13, 2015 20:40
-
-
Save andyinabox/da115091d597e60e015b to your computer and use it in GitHub Desktop.
Revisions
-
andyinabox revised this gist
Nov 13, 2015 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -11,7 +11,6 @@ class Blinky { int delayTimeOn; int ledState; int ledPin; public: Blinky(int pin, int timeOn) { -
daytona1 revised this gist
Nov 13, 2015 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -9,7 +9,6 @@ class Blinky { unsigned long t; unsigned long curTime; int delayTimeOn; int ledState; int ledPin; bool onMode; -
daytona1 revised this gist
Nov 13, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ # Separate Class File example First I made a new file called "blinky.h" in the Arduino IDE with the "New Tab" option. You might have to save the project **before** doing this to make sure it gets saved in the right place.  -
daytona1 created this gist
Nov 13, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ #include "blinky.h" Blinky led1(13, 1000); Blinky led2(12, 500); void setup() { // put your setup code here, to run once: } void loop() { // put your main code here, to run repeatedly: led1.upd8(); led2.upd8(); } This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ # Separate Class File example First I made a new file called "blinky.h" in the Arduino IDE.  When you save the project it should have this structure: ``` BlinkyClass/ - BlinkyClass.pde - blinky.h ``` The `.h` file had to use a different structure than the main file (see below). See the [Arduino Library Tuturial](https://www.arduino.cc/en/Hacking/LibraryTutorial) for more info. This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,45 @@ #ifndef Morse_h #define Morse_h #include "Arduino.h" // classes should always be defined first! class Blinky { unsigned long t; unsigned long curTime; int delayTimeOn; int delayTimeOff; int ledState; int ledPin; bool onMode; public: Blinky(int pin, int timeOn) { ledPin = pin; delayTimeOn = timeOn; pinMode(ledPin, OUTPUT); } void upd8() { t = millis(); if(t - curTime >= delayTimeOn) { curTime = t; if(ledState == LOW) { digitalWrite(ledPin, HIGH); ledState = HIGH; } else { digitalWrite(ledPin, LOW); ledState = LOW; } } } }; #endif