Willing to pay someone to finish this coding.

Anyone interested in making a little cash? I need to finish up this project and I'm running out of time. I realize I've bitten off more that I can chew but I'm more than halfway finished. The first code below is what ChrisTenone wrote for me to get me a Countdown timer. But I need it to do more.

After the first code below are the 4 things I need it to do. And I don't know how to write the code to make it happen. After that is the code that I have gotten to work the rest of the project. Ultimately, I would like to incorporate the Countdown code into the other code, to be a seamless program.

If there is a better countdown code that works with the Adafruit 7-segment, I2C, LED backpack display, that will accomplish what I want, I am open to suggestions. I'm even open to suggestions on the Wire Cutting sequence code, if it helps. I'm not saying that it's the best way to do it, just, this is what I have working the way I need it to. I've got it prototyped and working on a bread board.

I have a hand drawn sketch of the schematic of what I have working, if that helps. I can scan and attach it or try to draw it on the computer.

If you are interested, and can help, I guess you can email me or direct message. not sure how that works here. And /or reply here and lets discuss it. I'm not interested in having someone try to teach me how to write it. I've been doing that for the past month. I need someone to write it for me.

Thanks in advance, Mark

ridenhr:
/***********************************************

  • Count down using millis()
  • Adafruit 7-segment, I2C, LED backpack display
  • pin A5 -> C (on 7-segment)
  • pin A4 -> D (on 7-segment)

************************************************/

#include <Wire.h>
#include "Adafruit_GFX.h"
#include "Adafruit_LEDBackpack.h"
Adafruit_7segment matrix = Adafruit_7segment();

unsigned long previousSecondMillis = 0UL;
long oneSecond = 1000UL; // milliseconds per second

#define startMinute 4 // Modify these defines to
#define startSecond 59 // change the timer interval
int minutes = startMinute;
int seconds = startSecond;

void setup()
{
matrix.begin(0x72);
}

void loop() {

// --------- Run this every second ------------------
if (millis() - previousSecondMillis >= oneSecond) {

matrix.writeDigitNum(0, (minutes / 10));
matrix.writeDigitNum(1, (minutes % 10));
matrix.writeDigitNum(3, (seconds / 10));
matrix.writeDigitNum(4, (seconds % 10));
matrix.writeDisplay();

if (seconds-- == 0) {
if (minutes == 0) {
minutes = startMinute;
seconds = startSecond;
delay(1000);
} else {
minutes -= 1;
seconds = 59;
}
}

previousSecondMillis += oneSecond;
}
}

I got the countdown timer working, that Chris wrote above. Now what I need to accomplish is;

  1. To have it START with a momentary push button.

  2. Have it STOP when signal from another program on another Arduino is received. (See below, Drawer HIGH signal)

  3. Once the STOP signal is received, have it PAUSE for 10 seconds and RESET the countdown time to 20 seconds and continue counting down.

  4. When it reaches the end either by NOT receiving the STOP signal in time or after the PAUSE & RESET, to send a signal to activate some special effects. (digitalWrite(smoke, light , sound, HIGH);

Ideally, could I incorporate this code into the below code to run it all on the one Arduino UNO in one code? Pins 9,8,3,2,1,0,A0,A1,A2,A3 are all available.

The code below is working as it should, and I've gotten all the "hardware" working with it. Getting ready to take it from breadboard to soldered Board.

/*Wire Cutting sequence   

Cut the right wires in the right order and you win. Cut the wrong wire and or in the wrong order,
  and you lose, and the special effect activates.
*/

const int  wrongWire = 13; // the number of the cut wire pin
const int firstWire = 12;  // the number of the first wire pin
const int secondWire = 11;  // the number of the second wire pin
const int thirdWire = 10;  // the number of the third wire pin
const int smoke = 7;  // the number of the smoke pin
const int light = 6;  // the number of the light pin
const int sound = 5;  // the number of the sound pin
const int drawer = 4;  // the number of the drawer pin
//int firstWireState = digitalRead(firstWire);
//int secondWireState = digitalRead(secondWire);
//int thirdWireState = digitalRead(thirdWire);

void setup()
{
  pinMode(wrongWire, INPUT);
  pinMode(firstWire, INPUT);
  pinMode(secondWire, INPUT);
  pinMode(thirdWire, INPUT);
  pinMode(smoke, OUTPUT);
  pinMode(light, OUTPUT);
  pinMode(sound, OUTPUT);
  pinMode(drawer, OUTPUT);
}

void loop(){
//represents the wrong wire being cut at any time.
  if (digitalRead(wrongWire) == HIGH) {
    digitalWrite(smoke, HIGH);
    digitalWrite(sound, HIGH);
    digitalWrite(light, HIGH);
    delay(500);
    digitalWrite(light, LOW);
    digitalWrite(sound, LOW);
    delay(900000);  //15 minute delay
    //digitalWrite(smoke, digitalRead(wrongWire));
    //digitalWrite(light, digitalRead(wrongWire));
    //digitalWrite(sound, digitalRead(wrongWire));
}

//reminder to self: HIGH is wire Cut, LOW is wire Intact
    //To set off effects when second wire is cut before the first wire is cut
if (digitalRead(secondWire) == HIGH && digitalRead(firstWire) == LOW) {
  digitalWrite(smoke, HIGH);
  digitalWrite(sound, HIGH);
    digitalWrite(light, HIGH);
    delay(500);
    digitalWrite(light, LOW);
    digitalWrite(sound, LOW);
    delay(900000);  //15 minute delay
}
  //To set off effects when third wire is cut before the first or second wire is cut
if (digitalRead(thirdWire) == HIGH && digitalRead(secondWire) == LOW)  {
  digitalWrite(smoke, HIGH);
  digitalWrite(sound, HIGH);
  digitalWrite(light, HIGH);
    delay(500);
    digitalWrite(light, LOW);
    digitalWrite(sound, LOW);
    delay(900000);  //15 minute delay
}

if (digitalRead(thirdWire) == HIGH && digitalRead(firstWire) == LOW){
  digitalWrite(smoke, HIGH);
    digitalWrite(sound, HIGH);
    digitalWrite(light, HIGH);
    delay(500);
    digitalWrite(light, LOW);
    digitalWrite(sound, LOW);
    delay(900000);  //15 minute delay
}
if (digitalRead(thirdWire) == HIGH && digitalRead(secondWire) == HIGH && digitalRead(firstWire) == HIGH) {
  delay(1000);
  digitalWrite(drawer, HIGH);
  delay(1000);
  digitalWrite(drawer, LOW);
}

}




I realize I'm asking a lot, but I really need to get this working. And I greatly appreciate your assistance, in advance!!

Mark

Incorporating the start and stop switches is trivial. Introduce a global variable, of type boolean, called countingDown. Set it to false.

When the start switch becomes pressed (see the state change detection example), set countingDown to true.

When the stop switch becomes pressed (see the state change detection example), set countingDown to false.

Consider the state of the variable in deciding whether it is time to change the displayed time:

 // --------- Run this every second if counting down ------------------
  if (millis() - previousSecondMillis >= oneSecond && countingDown)
  { // Down here, where it belongs
  1. Once the STOP signal is received, have it PAUSE for 10 seconds and RESET the countdown time to 20 seconds and continue counting down.

So, the stop button needs to do more than setting countingDown to false, but this isn't really that difficult. Add another boolean, suspended, initialized to false, set to true when the stop switch becomes pressed, along with changing the time being counted down.

If the suspended variable contains true, and has contained true for 10 seconds, set countingDown to true and suspended to false.

  1. When it reaches the end either by NOT receiving the STOP signal in time or after the PAUSE & RESET, to send a signal back to the other Arduino to activate some special effects. (digitalWrite(smoke, light , sound, HIGH);

What kind of signal? Should the first Arduino let a little magic smoke out? Can the second Arduino read smoke signals?

While the idea is understandable, there isn't a chance that one could write any code for either Arduino based only on this requirement statement.

The button is ONLY to Start the countdown. After that it should do noting if pressed.

The STOP signal comes from the wire cutting sequence code.

}
if (digitalRead(thirdWire) == HIGH && digitalRead(secondWire) == HIGH && digitalRead(firstWire) == HIGH) {
  delay(1000);
  digitalWrite(drawer, HIGH);
  delay(1000);
  digitalWrite(drawer, LOW);
}

if this part is activated, then I would like the countdown to reset to 20 seconds and start counting down from 20 seconds.

  1. When it reaches the end either by NOT receiving the STOP signal in time or after the PAUSE & RESET, to send a signal back to the other Arduino to activate some special effects. (digitalWrite(smoke, light , sound, HIGH);

What kind of signal? Should the first Arduino let a little magic smoke out? Can the second Arduino read smoke signals?

While the idea is understandable, there isn't a chance that one could write any code for either Arduino based only on this requirement statement.

Sorry, I meant to take out the reference to the second Arduino. I would prefer that the "countdown" code and the "wire cutting sequence" code be combined and run off one Arduino.

So that when the countdown was completed the effects would be set off

 if (digitalRead(countdown timer expires) ) {
    digitalWrite(smoke, HIGH);
    digitalWrite(sound, HIGH);
    digitalWrite(light, HIGH);
}

or the proper equivalent.

As far as your statements at the beginning of your reply;

Incorporating the start and stop switches is trivial. Introduce a global variable, of type boolean, called countingDown. Set it to false.

When the start switch becomes pressed (see the state change detection example), set countingDown to true.

When the stop switch becomes pressed (see the state change detection example), set countingDown to false.

Consider the state of the variable in deciding whether it is time to change the displayed time:
Code: [Select]

// --------- Run this every second if counting down ------------------
if (millis() - previousSecondMillis >= oneSecond && countingDown)
{ // Down here, where it belongs

Quote

  1. Once the STOP signal is received, have it PAUSE for 10 seconds and RESET the countdown time to 20 seconds and continue counting down.

So, the stop button needs to do more than setting countingDown to false, but this isn't really that difficult. Add another boolean, suspended, initialized to false, set to true when the stop switch becomes pressed, along with changing the time being counted down.

If the suspended variable contains true, and has contained true for 10 seconds, set countingDown to true and suspended to false.

If you could put that into code format, that I can cut and paste into my code. This is why I'm willing to pay, I don't understand how to incorporate anything you just said. I don't know HOW to

Introduce a global variable, of type boolean, called countingDown. Set it to false.

Thanks for your interest and advice.

If you could put that into code format, that I can cut and paste into my code.

For the start switch:

Global variables:

bool countingDown = false;

byte currStartState;
byte prevStartState = HIGH; // Or LOW, if LOW means not pressed

Add to loop():

   currStartState = digitalRead(startPin);
   if(currStartState != prevStartState)
   {
      if(currStartState == LOW) // Or HIGH, if HIGH means pressed
      {
         countingDown = true;
      }
   }
   prevStartState = currStartState;

I'm sure that you have your reasons for the stop switch (the proper "bomb deactivation steps") re-arm the bomb, but they don't make sense to me. Anyone looking at the countdown timer running again after the wires were "cut" will be having a WTF moment.

I'm sure that you have your reasons for the stop switch (the proper "bomb deactivation steps") re-arm the bomb, but they don't make sense to me. Anyone looking at the countdown timer running again after the wires were "cut" will be having a WTF moment.

That is exactly what I want.... that WTF moment. But also, we have such a lot in the Special Effect, Light flashing, Smoke and Explosion sound, it seems a shame you don't get to experience it if you win the game by beating the clock. So we decided, win or lose, the "bomb" explodes....

Thanks for your help. I'll try to put this in my code, I assume this is just ti start the time. But how do I incorporate the start button?

OK Paul, I added your code and included a Start Button. But as soon as I load the code, it starts counting down and the button has no effect. What am I doing wrong?

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_LEDBackpack.h>
Adafruit_7segment matrix = Adafruit_7segment();

unsigned long previousSecondMillis = 0UL;
long oneSecond = 1000UL; // milliseconds per second

#define startMinute 59  //  Modify these defines to
#define startSecond 59 // change the timer interval
int minutes = startMinute;
int seconds = startSecond;
int isCountingDown = true;
const int startPin = 9;  //push button to start the timer

bool countingDown = false;

byte currStartState;
byte prevStartState = LOW; // Or LOW, if LOW means not pressed


void setup()
{
  matrix.begin(0x70);
  pinMode(startPin, INPUT);
}

void loop() {

     currStartState = digitalRead(startPin);
   if(currStartState != prevStartState)
   {
      if(currStartState == HIGH) // Or HIGH, if HIGH means pressed
      {
         countingDown = true;
      }
   }
   prevStartState = currStartState;

  // --------- Run this every second ------------------
  if (millis() - previousSecondMillis >= oneSecond) {

    matrix.writeDigitNum(0, (minutes / 10));
    matrix.writeDigitNum(1, (minutes % 10));
    matrix.writeDigitNum(3, (seconds / 10));
    matrix.writeDigitNum(4, (seconds % 10));
    matrix.writeDisplay();

//if (isCountingDown) {
    if (seconds-- == 0) {
      if (minutes == 0) {
        minutes = startMinute;
        seconds = startSecond;
        delay(1000);
      } else {
        minutes -= 1;
        seconds = 59;
      }
    }
//}
    previousSecondMillis += oneSecond;
  }
}

What am I doing wrong?

I'd guess that the wiring if the switch does not match what the code expects.

You are not using INPUT_PULLUP as the mode for the switch pin, so this implies that you are using an external resistor, in either pullup or pulldown configuration.

The comparison to HIGH in the if statement implies that the resistor is in the pulldown configuration. Is this really the case?

If so, why? Using the internal pullup resistor, and connecting one leg of the switch to ground and the other leg to the digital pin is so much easier. Of course, this means that LOW is pressed, but that is not a big deal.

That is exactly what I want.... that WTF moment. But also, we have such a lot in the Special Effect, Light flashing, Smoke and Explosion sound, it seems a shame you don't get to experience it if you win the game by beating the clock. So we decided, win or lose, the "bomb" explodes....

I'd just walk away at that point. Having another, hidden/more complex) bomb start counting down, when I disabled the easy to find/easy to disable one, on the other hand, might make sense. YMMV.

Paul,

Attached is a schematic of how I have the push button connected. I'm using an external resistor connected to the ground. That is how I ASSUMED it needed to be connected based on previous tutorials and codes I've tried.

Your way is better, which I would assume. Please tell me EXACTLY how to hook it up.

The answer to your question "WHY?" is because I don't know any better. I haven't quite grasped the difference between INPUT_PULLUP and INPUT_PULLDOWN, nor how to apply them to a code. I've seen it before but ....

I really appreciate you trying to help me fix my code on my own, BUT I would rather pay you or someone to do it for me. Are you interested?

Mark

Mark:
I'm going to send you a PM to offer to complete this for you. However, I may suggest alternate hardware: my experience is that I can finish these kinds of things much, much faster if I start from the beginning with hardware I have on hand instead of trying to patch together something already started.

I'd much rather ship a complete, working item instead of bits and pieces.

Please tell me EXACTLY how to hook it up.

I did. A switch only has two legs. They are completely interchangeable. One goes to ground. One goes to the digital pin. Just like your diagram, except without the external resistor.

PaulS:
I did. A switch only has two legs. They are completely interchangeable. One goes to ground. One goes to the digital pin. Just like your diagram, except without the external resistor.

Paul,

As much as I appreciate you trying to help me write the code on my own, That is not what I was asking for. I've been trying to write the code myself for over a month now and I've gotten far but not quite there yet.

Any way, I went onto the Upwork site and posted my project and within hours, I hired someone to finish out the code for me. Less than 18 hours later, (and only because there was a 7 hour time difference) I have a fully working sketch.

I highly recommend the Upwork site. It's easy to find someone willing to do the work and at a price I could live with.

Thanks for trying, I'll be posting any future projects that I can't figure out on Upwork from now own.

I don't know how to list this topic as solved, but it is.