Page 2 of 2
Re: Help to modify Arduino code
Posted: 23 Jun 2018, 00:17
by Scott Todd
I added some Serial.print lines to help with debugging. The millis() is NOT returning a value.
Ugggghh....This has to be something simple...
Re: Help to modify Arduino code
Posted: 16 Jul 2018, 23:01
by jmendoza
Hey Scott, I can kick you after 5 minutes, no charge

Re: Help to modify Arduino code
Posted: 17 Jul 2018, 00:28
by Phil_G
Just an observation Scott, you're not initialising buttonPressedMillis, so it has an unknown value.
When the button is pressed, you assign it a value (the current time), but until then, and during the tests in line 112, it could be anything.
Re: Help to modify Arduino code
Posted: 17 Jul 2018, 16:33
by Scott Todd
Good catch Phil. It gets declared in 111 but I see your point. I may go back and re-visit it. I decided to punt and start over. Its boring to most but for the record, here is what I did. I'll add a switched Digital input to select two different values eventually. Again, the point is to do spot landings and 'mini' contests with friends. And get some practice coding again. No matter how simple....
static int timedButton = 2, timerLED=3; //Added by *** Scott Todd ***
unsigned int motorTimer=0, motorCut=0, motorDuration=150; // 50 hz or 50 = 1 second, so 150=3sec for testing
pinMode(timedButton, INPUT_PULLUP); //Added by *** Scott Todd ***
pinMode(timerLED, OUTPUT); //Added by *** Scott Todd ***
// This is added just after inactivity near end of code.
// I added the LED for de-bugging and decided I liked it. It stays on during the timing cycle.
// **** MotorTimer Added by Scott Todd
if (digitalRead(timedButton) == 0) {
motorCut=1;
}
if (motorCut==1) {
motorTimer++;
digitalWrite(timerLED, HIGH);
}
if (motorTimer > motorDuration) {
tlock=1;
motorTimer=0;
motorCut=0;
digitalWrite(timerLED, LOW);
}