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;
To have it START with a momentary push button.
Have it STOP when signal from another program on another Arduino is received. (See below, Drawer HIGH signal)
Once the STOP signal is received, have it PAUSE for 10 seconds and RESET the countdown time to 20 seconds and continue counting down.
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
