Instantly share code, notes, and snippets.

Embed
What would you like to do?
Smart barn door tracker. Arduino source code
/*
Copyright 2018 Arun Venkataswamy
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "TimerOne.h"
#include "MsTimer2.h"
#include <avr/pgmspace.h>
// Number of steps to reach the upper end of the threaded rod.
// The tracking will stop once this upper limit is reached.
// Eg. For 8mm pitch, 300mm length, 1/32 microsteps,
// 200 full steps per revolution
// (300/8)x200x32 = 240000
#define UPPER_LIMIT 240000
//Pins controlling outputs
const int LEDDx = 7;
const int homePin = 2;
const int enablePin = 10;
const int pulsePin = 11;
const int dirPin = 12;
//Pins controlling inputs
const int buttonPausePin = 5;
const int buttonPlayPin = 6;
const int buttonRewindPin = 3;
const int buttonFastForwardPin = 4;
//Flags and variables
const int directionForward = 0;
const int directionReverse = 1;
bool buttonChange = false;
int buttonPause = 0;
int buttonPlay = 0;
int buttonRewind = 0;
int buttonFastForward = 0;
int obuttonPause = 0;
int obuttonPlay = 0;
int obuttonRewind = 0;
int obuttonFastForward = 0;
int home = 1;
bool homeIsKnown = false;
bool movingBackwards = false;
unsigned long position = 0;
bool isMoving = false;
bool isTracking = false;
int currTime = 0;
int currFreq = 0;
int lookupLength = 0;
int t500step = 0;
unsigned int newTimerValue;
//Precalculated lookup table for tangent error correction
const PROGMEM uint32_t timerLookup[] = {28229,28229,28230,28230,28230,28231,28231,28231,28231,28232,28232,28232,28232,28233,28233,28233,28233,28234,28234,28234,28235,28235,28235,28235,28236,28236,28236,28237,28237,28237,28237,28238,28238,28238,28239,28239,28239,28239,28240,28240,28240,28241,28241,28241,28242,28242,28242,28242,28243,28243,28243,28244,28244,28244,28245,28245,28245,28246,28246,28246,28246,28247,28247,28247,28248,28248,28248,28249,28249,28249,28250,28250,28250,28251,28251,28251,28252,28252,28252,28253,28253,28253,28254,28254,28254,28255,28255,28255,28256,28256,28256,28257,28257,28257,28258,28258,28259,28259,28259,28260,28260,28260,28261,28261,28261,28262,28262,28262,28263,28263,28264,28264,28264,28265,28265,28265,28266,28266,28266,28267,28267,28268,28268,28268,28269,28269,28269,28270,28270,28271,28271,28271,28272,28272,28273,28273,28273,28274,28274,28275,28275,28275,28276,28276,28276,28277,28277,28278,28278,28278,28279,28279,28280,28280,28281,28281,28281,28282,28282,28283,28283,28283,28284,28284,28285,28285,28285,28286,28286,28287,28287,28288,28288,28288,28289,28289,28290,28290,28291,28291,28291,28292,28292,28293,28293,28294,28294,28295,28295,28295,28296,28296,28297,28297,28298,28298,28299,28299,28299,28300,28300,28301,28301,28302,28302,28303,28303,28304,28304,28304,28305,28305,28306,28306,28307,28307,28308,28308,28309,28309,28310,28310,28311,28311,28311,28312,28312,28313,28313,28314,28314,28315,28315,28316,28316,28317,28317,28318,28318,28319,28319,28320,28320,28321,28321,28322,28322,28323,28323,28324,28324,28325,28325,28326,28326,28327,28327,28328,28328,28329,28329,28330,28330,28331,28331,28332,28332,28333,28333,28334,28334,28335,28336,28336,28337,28337,28338,28338,28339,28339,28340,28340,28341,28341,28342,28342,28343,28344,28344,28345,28345,28346,28346,28347,28347,28348,28348,28349,28350,28350,28351,28351,28352,28352,28353,28353,28354,28355,28355,28356,28356,28357,28357,28358,28358,28359,28360,28360,28361,28361,28362,28362,28363,28364,28364,28365,28365,28366,28367,28367,28368,28368,28369,28369,28370,28371,28371,28372,28372,28373,28374,28374,28375,28375,28376,28377,28377,28378,28378,28379,28380,28380,28381,28381,28382,28383,28383,28384,28384,28385,28386,28386,28387,28388,28388,28389,28389,28390,28391,28391,28392,28393,28393,28394,28394,28395,28396,28396,28397,28398,28398,28399,28399,28400,28401,28401,28402,28403,28403,28404,28405,28405,28406,28407,28407,28408,28409,28409,28410,28410,28411,28412,28412,28413,28414,28414,28415,28416,28416,28417,28418,28418,28419,28420,28420,28421,28422,28422,28423,28424,28424,28425,28426,28427,28427,28428,28429,28429,28430,28431,28431,28432,28433,28433,28434,28435,28435,28436,28437,28438,28438,28439,28440,28440,28441,28442,28442,28443,28444,28445,28445,28446,28447,28447,28448,28449,28450,28450,28451,28452,28452,28453,28454,28455,28455,28456,28457,28458,28458,28459,28460,28460,28461,28462,28463,28463,28464,28465,28466,28466,28467,28468,28469,28469,28470,28471,28472,28472,28473,28474,28475,28475,28476,28477,28478,28478,28479,28480,28481,28481,28482,28483,28484,28484,28485,28486,28487,28487,28488,28489,28490,28491,28491,28492,28493,28494,28494,28495,28496,28497,28498,28498,28499,28500,28501,28502,28502,28503,28504,28505,28506,28506,28507,28508,28509,28510,28510,28511,28512,28513,28514,28514,28515,28516,28517,28518,28518,28519,28520,28521,28522,28522,28523,28524,28525,28526,28527,28527,28528,28529,28530,28531,28532,28532,28533,28534,28535,28536,28537,28537,28538,28539,28540,28541,28542,28542,28543,28544,28545,28546,28547,28548,28548,28549,28550,28551,28552,28553,28554,28554,28555,28556,28557,28558,28559,28560,28560,28561,28562,28563,28564,28565,28566,28567,28567,28568,28569,28570,28571,28572,28573,28574,28575,28575,28576,28577,28578,28579,28580,28581,28582,28583,28583,28584,28585,28586,28587,28588,28589,28590,28591,28592,28593,28593,28594,28595,28596,28597,28598,28599,28600,28601,28602,28603,28604,28604,28605,28606,28607,28608,28609,28610,28611,28612,28613,28614,28615,28616,28617,28618,28619,28619,28620,28621,28622,28623,28624,28625,28626,28627,28628,28629,28630,28631,28632,28633,28634,28635,28636,28637,28638,28639,28640,28641,28641,28642,28643,28644,28645,28646,28647,28648,28649,28650,28651,28652,28653,28654,28655,28656,28657,28658,28659,28660,28661,28662,28663,28664,28665,28666,28667,28668,28669,28670,28671,28672,28673,28674,28675,28676,28677,28678,28679,28680,28681,28682,28683,28684,28685,28686,28687,28688,28689,28690,28692,28693,28694,28695,28696,28697,28698,28699,28700,28701,28702,28703,28704,28705,28706,28707,28708,28709,28710,28711,28712,28713,28714,28716,28717,28718,28719,28720,28721,28722,28723,28724,28725,28726,28727,28728,28729,28730,28732,28733,28734,28735,28736,28737,28738,28739,28740,28741,28742,28743,28745,28746,28747,28748,28749,28750,28751,28752,28753,28754,28756,28757,28758,28759,28760,28761,28762,28763,28764,28766,28767,28768,28769,28770,28771,28772,28773,28774,28776,28777,28778,28779,28780,28781,28782,28784,28785,28786,28787,28788,28789,28790,28792,28793,28794,28795,28796,28797,28798,28800,28801,28802,28803,28804,28805,28806,28808,28809,28810,28811,28812,28813,28815,28816,28817,28818,28819,28820,28822,28823,28824,28825,28826,28828,28829,28830,28831,28832,28834,28835,28836,28837,28838,28839,28841,28842,28843,28844,28845,28847,28848,28849,28850,28852,28853,28854,28855,28856,28858,28859,28860,28861,28862,28864,28865,28866,28867,28869,28870,28871,28872,28873,28875,28876,28877,28878,28880,28881,28882,28883,28885,28886,28887,28888,28890,28891,28892,28893,28895,28896,28897,28898,28900,28901,28902,28903,28905,28906,28907,28909,28910,28911,28912,28914,28915,28916,28917,28919,28920,28921,28923,28924,28925,28926,28928,28929,28930,28932,28933,28934,28935,28937,28938,28939,28941,28942,28943,28945,28946,28947,28949,28950,28951,28952,28954,28955,28956,28958,28959,28960,28962,28963,28964,28966,28967,28968,28970,28971,28972,28974,28975,28976,28978,28979,28980,28982,28983,28984,28986,28987,28988,28990,28991,28993,28994,28995,28997,28998,28999,29001,29002,29003,29005,29006,29008,29009,29010,29012,29013,29014,29016,29017,29019,29020,29021,29023,29024,29025,29027,29028,29030,29031,29032,29034,29035,29037,29038,29039,29041,29042,29044,29045,29046,29048,29049,29051,29052,29054,29055,29056,29058,29059,29061,29062,29064,29065,29066,29068,29069,29071,29072,29074,29075,29076,29078,29079,29081,29082,29084,29085,29087,29088,29089,29091,29092,29094,29095,29097,29098,29100,29101,29103,29104,29106,29107,29108,29110,29111,29113,29114,29116,29117,29119,29120,29122,29123,29125,29126,29128,29129,29131,29132,29134,29135,29137,29138,29140,29141,29143,29144,29146,29147,29149,29150,29152,29153,29155,29156,29158,29159,29161,29162,29164,29165,29167,29169,29170,29172,29173,29175,29176,29178,29179,29181,29182,29184,29185,29187,29189,29190,29192,29193,29195,29196,29198,29199,29201,29203,29204,29206,29207,29209,29210,29212,29214,29215,29217,29218,29220,29221,29223,29225,29226,29228,29229,29231,29233,29234,29236,29237,29239,29241,29242,29244,29245,29247,29249,29250,29252,29253,29255,29257,29258,29260,29262,29263,29265,29266,29268,29270,29271,29273,29275,29276,29278,29279,29281,29283,29284,29286,29288,29289,29291,29293,29294,29296,29298,29299,29301,29303,29304,29306,29308,29309,29311,29313,29314,29316,29318,29319,29321,29323,29324,29326,29328,29329,29331,29333,29334,29336,29338,29339,29341,29343,29345,29346,29348,29350,29351,29353,29355,29357,29358,29360,29362,29363,29365,29367,29369,29370,29372,29374,29375,29377,29379,29381,29382,29384,29386,29388,29389,29391,29393,29395,29396,29398,29400,29402,29403,29405,29407,29409,29410,29412,29414,29416,29417,29419,29421,29423,29425,29426,29428,29430,29432,29433,29435,29437,29439,29441,29442,29444,29446,29448,29450,29451,29453,29455,29457,29459,29460,29462,29464,29466,29468,29469,29471,29473,29475,29477,29479,29480,29482,29484,29486,29488,29490,29491,29493,29495,29497,29499,29501,29502,29504,29506,29508,29510,29512,29514,29515,29517,29519,29521,29523,29525,29527,29528,29530,29532,29534,29536,29538,29540,29542,29544,29545,29547,29549,29551,29553,29555,29557,29559,29561,29562,29564,29566,29568,29570,29572,29574,29576,29578,29580,29582,29584,29585,29587,29589,29591,29593,29595,29597,29599,29601,29603,29605,29607,29609,29611,29613,29615,29616,29618,29620,29622,29624,29626,29628,29630,29632,29634,29636,29638,29640,29642,29644,29646,29648,29650,29652,29654,29656,29658,29660,29662,29664,29666,29668,29670,29672,29674,29676,29678,29680,29682,29684,29686,29688,29690,29692,29694,29696,29698,29700,29702,29704,29706,29708,29710,29712,29714,29716,29718,29721,29723,29725,29727,29729,29731,29733,29735,29737,29739,29741,29743,29745,29747,29749,29751,29754,29756,29758,29760,29762,29764,29766,29768,29770,29772,29774,29777,29779,29781,29783,29785,29787,29789,29791,29793,29796,29798,29800,29802,29804,29806,29808,29810,29813,29815,29817,29819,29821,29823,29825,29828,29830,29832,29834,29836,29838,29840,29843,29845,29847,29849,29851,29853,29856,29858,29860,29862,29864,29866,29869,29871,29873,29875,29877,29880,29882,29884,29886,29888,29891,29893,29895,29897,29899,29902,29904,29906,29908,29911,29913,29915,29917,29919,29922,29924,29926,29928,29931,29933,29935,29937,29940,29942,29944,29946,29949,29951,29953,29955,29958,29960,29962,29964,29967,29969,29971,29974,29976,29978,29980,29983,29985,29987,29990,29992,29994,29996,29999,30001,30003,30006,30008,30010,30013,30015,30017,30020,30022,30024,30027,30029,30031,30034,30036,30038,30041,30043,30045,30048,30050,30052,30055,30057,30059,30062,30064,30066,30069,30071,30074,30076,30078,30081,30083,30085,30088,30090,30093,30095,30097,30100,30102,30105,30107,30109,30112,30114,30117,30119,30121,30124,30126,30129,30131,30133,30136,30138,30141,30143,30146,30148,30150,30153,30155,30158,30160,30163,30165,30168,30170,30173,30175,30177,30180,30182,30185,30187,30190,30192,30195,30197,30200,30202,30205,30207,30210,30212,30215,30217,30220,30222,30225,30227,30230,30232,30235,30237,30240,30242,30245,30247,30250,30252,30255,30257,30260,30263,30265,30268,30270,30273,30275,30278,30280,30283,30286,30288,30291,30293,30296,30298,30301,30304,30306,30309,30311,30314,30316,30319,30322,30324,30327,30329,30332,30335,30337,30340,30342,30345,30348,30350,30353,30356,30358,30361,30363,30366,30369,30371,30374,30377,30379,30382,30385,30387,30390,30393,30395,30398,30401,30403,30406,30409,30411,30414,30417,30419,30422,30425,30427,30430,30433,30435,30438,30441,30444,30446,30449,30452,30454,30457,30460,30463,30465,30468,30471,30473,30476,30479,30482,30484,30487,30490,30493,30495,30498,30501,30504,30506,30509,30512,30515,30517,30520,30523,30526,30529,30531,30534,30537,30540,30543,30545,30548,30551,30554,30557,30559,30562,30565,30568,30571,30573,30576,30579,30582,30585,30588,30590,30593,30596,30599,30602,30605,30607,30610,30613,30616,30619,30622,30625,30628,30630,30633,30636,30639,30642,30645,30648,30651,30653,30656,30659,30662,30665,30668,30671,30674,30677,30680,30683,30686,30688,30691,30694,30697,30700,30703,30706,30709,30712,30715,30718,30721,30724,30727,30730,30733,30736,30739,30742,30745,30748,30751,30753,30756,30759,30762,30765,30768,30771,30774,30777,30780,30784,30787,30790,30793,30796,30799,30802,30805,30808,30811,30814,30817,30820,30823,30826,30829,30832,30835,30838,30841,30844,30847,30851,30854,30857,30860,30863,30866,30869,30872,30875,30878,30881,30885,30888,30891,30894,30897,30900,30903,30906,30909,30913,30916,30919,30922,30925,30928,30931,30935,30938,30941,30944,30947,30950,30954,30957,30960,30963,30966,30969,30973,30976,30979,30982,30985,30989,30992,30995,30998,31001,31005,31008,31011,31014,31018,31021,31024,31027,31031,31034,31037,31040,31044,31047,31050,31053,31057,31060,31063,31066,31070,31073,31076,31080,31083,31086,31089,31093,31096,31099,31103,31106,31109,31113,31116,31119,31123,31126,31129,31133,31136,31139,31143,31146,31149,31153,31156,31159,31163,31166,31169,31173,31176,31180,31183,31186,31190,31193,31196,31200,31203,31207,31210,31214,31217,31220,31224,31227,31231,31234,31237,31241,31244,31248,31251,31255,31258,31262,31265,31269,31272,31275,31279,31282,31286,31289,31293,31296,31300,31303,31307,31310,31314,31317,31321,31324,31328,31331,31335,31338,31342,31345,31349,31353,31356,31360,31363,31367,31370,31374,31377,31381,31385,31388,31392,31395,31399,31402,31406,31410,31413,31417,31420,31424,31428,31431,31435,31439,31442,31446,31449,31453,31457,31460,31464,31468,31471,31475,31479,31482,31486,31490,31493,31497,31501,31504,31508,31512,31515,31519,31523,31526,31530,31534,31538,31541,31545,31549,31553,31556,31560,31564,31567,31571,31575,31579,31582,31586,31590,31594,31598,31601,31605,31609,31613,31616,31620,31624,31628,31632,31635,31639,31643,31647,31651,31655,31658,31662,31666,31670,31674,31678,31681,31685,31689,31693,31697,31701,31705,31708,31712,31716,31720,31724,31728,31732,31736,31740,31744,31747,31751,31755,31759,31763,31767,31771,31775,31779,31783,31787,31791,31795,31799,31803,31807,31811,31815,31819,31823,31827,31831,31835,31839,31843,31847,31851,31855,31859,31863,31867,31871,31875,31879,31883,31887};
void setup() {
//Initialize the serial port for printing debug messages
Serial.begin(9600);
Serial.println("Smart Barn door controller");
//Setting up all output ports
pinMode(LEDDx, OUTPUT);
pinMode(enablePin, OUTPUT);
pinMode(pulsePin, OUTPUT);
pinMode(dirPin, OUTPUT);
//Setting up all input ports
pinMode(homePin, INPUT);
digitalWrite(homePin, INPUT_PULLUP);
pinMode(buttonPausePin,INPUT);
digitalWrite(buttonPausePin, INPUT_PULLUP);
pinMode(buttonPlayPin,INPUT);
digitalWrite(buttonPlayPin, INPUT_PULLUP);
pinMode(buttonRewindPin,INPUT);
digitalWrite(buttonRewindPin, INPUT_PULLUP);
pinMode(buttonFastForwardPin,INPUT);
digitalWrite(buttonFastForwardPin, INPUT_PULLUP);
//We start with direction set to forward
digitalWrite(dirPin,directionForward);
//Disable the stepper motor driver on startup
//This is to save electric power till the user
//want to track. 1=Diable, 0=Enable
digitalWrite(enablePin,1);
isMoving = false;
lookupLength = sizeof(timerLookup) / sizeof(unsigned int);
//Main timer for controlling stepper motor speed
Timer1.initialize(500);
Timer1.attachInterrupt(timerCallback);
//Another timer to display status messages through DX LED.
MsTimer2::set(500, statusDisplay); // 500ms period
MsTimer2::start();
}
//Function to display various statuses through the DX LED
//Also handles changing stepper motor speed based on
//the lookup table for tangent error correction
void statusDisplay() {
//Status messages to debug. Please feel free to remove these
//once you are done debugging. No harm in them remaining here too
Serial.println("-----");
Serial.print(home);
Serial.print(buttonPause);
Serial.print(buttonPlay);
Serial.print(buttonRewind);
Serial.print(buttonFastForward);
Serial.println("+----");
if (!homeIsKnown)
//We still do not know the home position
//Indicate it with DX LED blinking
digitalWrite(LEDDx, digitalRead(LEDDx) ^ 1);
else {
if (home == 0) {
//At home position, we keep DX LED 'On'
digitalWrite(LEDDx,1);
} else {
digitalWrite(LEDDx,0);
}
//If we are tracking, we do slow blinking of DX LED
if (isTracking || isMoving) {
if (t500step < 5)
digitalWrite(LEDDx,1);
else
digitalWrite(LEDDx,0);
} else {
digitalWrite(LEDDx,0);
}
}
//We switch the stepper motor speed every 5 seconds
//to handle tangent error correction.
t500step++;
if (t500step == 10) { //Every 5 seconds
t500step = 0;
if (isMoving && isTracking) {
currTime++;
if (currTime < lookupLength) {
newTimerValue = pgm_read_dword_near(&timerLookup[currTime]);
Timer1.initialize(newTimerValue);
Timer1.attachInterrupt(timerCallback);
Serial.println("New timer freq");
Serial.println(newTimerValue);
}
}
}
Serial.println(position);
Serial.println(currTime);
Serial.println(".");
}
//Main timer callback function to pulse the stepper motor.
void timerCallback()
{
digitalWrite(pulsePin, digitalRead(pulsePin) ^ 1);
if (isMoving) {
if (movingBackwards) {
if (position > 0) position--;
} else position++;
}
}
//Arduino's loop
void loop() {
home = digitalRead(homePin);
if (home == 0) {
//We are at home.
homeIsKnown = true;
position = 0;
currTime = 0;
}
if (position > UPPER_LIMIT && movingBackwards == false) {
digitalWrite(enablePin,1);
isMoving = false;
}
//Detect user pressing buttons
buttonChange = false;
buttonPause = digitalRead(buttonPausePin);
buttonPlay = digitalRead(buttonPlayPin);
buttonRewind = digitalRead(buttonRewindPin);
buttonFastForward = digitalRead(buttonFastForwardPin);
//Debouncing and taking actions for button presses
if (buttonPause != obuttonPause) {
delay(50);
buttonPause = digitalRead(buttonPausePin);
if (buttonPause != obuttonPause) {
buttonChange = true;
obuttonPause = buttonPause;
}
}
if (buttonPlay != obuttonPlay) {
delay(50);
buttonPlay = digitalRead(buttonPlayPin);
if (buttonPlay != obuttonPlay) {
buttonChange = true;
obuttonPlay = buttonPlay;
}
}
if (buttonRewind != obuttonRewind) {
delay(50);
buttonRewind = digitalRead(buttonRewindPin);
if (buttonRewind != obuttonRewind) {
MsTimer2::set(500, statusDisplay); // Quick status blinking
MsTimer2::start();
if (buttonRewind == 1 && obuttonRewind == 0) {
//Stop movement.
digitalWrite(enablePin,1);
isMoving = false;
}
buttonChange = true;
obuttonRewind = buttonRewind;
}
}
if (buttonFastForward != obuttonFastForward) {
delay(50);
buttonFastForward = digitalRead(buttonFastForwardPin);
if (buttonFastForward != obuttonFastForward) {
MsTimer2::set(500, statusDisplay); // Quick status blinking
MsTimer2::start();
if (buttonFastForward == 1 && obuttonFastForward == 0) {
//Stop movement.
digitalWrite(enablePin,1);
isMoving = false;
}
buttonChange = true;
obuttonFastForward = buttonFastForward;
}
}
if (buttonChange) {
if (buttonRewind == 0 || buttonFastForward == 0) {
if (buttonRewind == 0) {
if (home == 1) digitalWrite(enablePin,0);
isMoving = true;
digitalWrite(dirPin,directionReverse);
movingBackwards = true;
isTracking = false;
currTime = 0;
Timer1.initialize(100); //Fast movement of stepper
MsTimer2::set(100, statusDisplay); // Quick status blinking
MsTimer2::start();
} else if (homeIsKnown) {
digitalWrite(enablePin,0);
isMoving = true;
digitalWrite(dirPin,directionForward);
movingBackwards = false;
isTracking = false;
Timer1.initialize(100); //Fast movement of stepper
MsTimer2::set(100, statusDisplay); // Quick status blinking
MsTimer2::start();
}
} else if (buttonPlay == 0) {
if (homeIsKnown) {
digitalWrite(dirPin,directionForward);
movingBackwards = false;
Timer1.initialize(21177);
MsTimer2::set(500, statusDisplay); // slow status blinking
MsTimer2::start();
digitalWrite(enablePin,0);
isMoving = true;
isTracking = true;
}
} else if (buttonPause == 0) {
digitalWrite(enablePin,1);
isMoving = false;
isTracking = false;
}
}
if (home == 0 && movingBackwards) {
digitalWrite(enablePin,1);
isMoving = false;
isTracking = false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment