1 wire came lose and I can't remember where it goes.
The other end of it is connected to the joystick switch and I believe it goes somewhere in the Arduino Uno R3.
Would mean the world to me if someone can help.
I feel your pain.
Is this something you slavishly copied, hardware and software, from some website? Say which if.
Did you design this? What is it, what does it do?
Can you draw a block diagram of this project?
Worst case, start now: trace all the wires and draw a schematic like the one you should have been working from in the first place!
If you draw a schematic and post the code, it may be way easier (possible) to figure out where that wire should go.
And please - get that dangling DuPont wired UNO secured before more wires jump free and
consider when this is over the advantages of wiring things a bit better, proper connectors and soldering and mechanical stability and stuff.
a7
Do you have a copy of the sketch that is programmed into the board?
You had a discussion on here a few months ago, with some code that appears to somewhat match the device you have pictured:
https://forum.arduino.cc/t/anyone-know-of-a-good-youtube-tutorial-on-how-to-make-a-code-repeat/1027637
I designed it myself and had help from others on this forum. The original design was on a bread board instead of the Uno and I have the plans for that. For some reason I decided to get an UNO and don't recall how I wired it.
Will definitely do a clean wire up and document the schematics when I figure it out.
Here is the code and schematic for the bread board and Nano. I've since upgraded to an UNO and it worked great until I accidentally unplugged it last night.
/*
Solenoid cycle
1) press momentary switch.
2) solenoid #1 activates for 4 seconds then turns off.
3) solenoid #2 waits 1 second after solenoid #1 activates, then it activates.
4) solenoid #3 waits 5 seconds after solenoid #1 activates, then it activates for 1 second and turns off.
The circuit:
* pushbutton attached to the pin 2 and to the ground
* solenoid #1 attached to pin 4
* solenoid #2 attached to pin 5
* solenoid #3 attached to pin 6
created 13 August 2022
by Automatisierung
*/
// constants won't change. They're used here to
const unsigned long solenoid_1_OffDelay = 4000; //4 seconds
const unsigned long solenoid_2_OnDelay = 1000; //1 second
const unsigned long solenoid_2_OffDelay = 5500; //1 second
const unsigned long solenoid_3_OnDelay = 5000; //5 seconds
const unsigned long solenoid_3_OffDelay = 1000; //1 second
// set pin numbers:
const int buttonPin = 2; // the number of the pushbutton pin
const int solenoid1Pin = 4; // solenoid 1 pin
const int solenoid2Pin = 5; // solenoid 2 pin
const int solenoid3Pin = 6; // solenoid 3 pin
// Variables will change:
unsigned long solenoid_1_Time = 0; //time for solenoid #1
unsigned long solenoid_2_Time = 0; //time for solenoid #2
unsigned long solenoid_3_Time = 0; //time for solenoid #3
int buttonState = HIGH; //the current reading from the input pin
int lastButtonState = HIGH; //the previous reading from the input pin
int isCycleRunning = LOW; //state of the cycle
int runSolenoid_1 = LOW; //activate solenoid #1
int runSolenoid_2 = LOW; //activate solenoid #2
int runSolenoid_3 = LOW; //activate solenoid #3
int stepSolenoid_1 = 0; //steps of solenoid #1
int stepSolenoid_2 = 0; //steps of solenoid #2
int stepSolenoid_3 = 0; //steps of solenoid #3
int solenoid_1_done = LOW;
int solenoid_2_done = LOW;
int solenoid_3_done = LOW;
// the following variables are unsigned long's because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
unsigned long lastDebounceTime = 0; // the last time the output pin was toggled
unsigned long debounceDelay = 50; // the debounce time; increase if the output flickers
void setup() {
pinMode(buttonPin, INPUT_PULLUP);
pinMode(solenoid1Pin, OUTPUT);
pinMode(solenoid2Pin, OUTPUT);
pinMode(solenoid3Pin, OUTPUT);
// set initial outputs state
digitalWrite(solenoid1Pin, LOW);
digitalWrite(solenoid2Pin, LOW);
digitalWrite(solenoid3Pin, LOW);
}
void loop() {
// read the state of the switch into a local variable:
int reading = digitalRead(buttonPin);
// check to see if you just pressed the button
// (i.e. the input went from LOW to HIGH), and you've waited
// long enough since the last press to ignore any noise:
// If the switch changed, due to noise or pressing:
if (reading != lastButtonState) {
// reset the debouncing timer
lastDebounceTime = millis();
}
if ((millis() - lastDebounceTime) > debounceDelay) {
// whatever the reading is at, it's been there for longer
// than the debounce delay, so take it as the actual current state:
// if the button state has changed:
if (reading != buttonState) {
buttonState = reading;
// only toggle the bit if the new button state is LOW
if (buttonState == LOW) {
isCycleRunning = !isCycleRunning;
runSolenoid_1 = HIGH;
}
}
}
if(!isCycleRunning){
// reset outputs state
digitalWrite(solenoid1Pin, LOW);
digitalWrite(solenoid2Pin, LOW);
digitalWrite(solenoid3Pin, LOW);
//reset the cycle
stepSolenoid_1 = 0;
stepSolenoid_2 = 0;
stepSolenoid_3 = 0;
runSolenoid_2 = LOW;
runSolenoid_3 = LOW;
solenoid_1_done = LOW;
solenoid_2_done = LOW;
solenoid_3_done = LOW;
}
//solenoid #1
switch(stepSolenoid_1) {
case 0: //start when the button is pressed
if (runSolenoid_1)
stepSolenoid_1 = 10;
break;
case 10: //solenoid #1 activates
digitalWrite(solenoid1Pin, HIGH);
runSolenoid_2 = HIGH;
runSolenoid_3 = HIGH;
stepSolenoid_1 = 11;
solenoid_1_Time = millis();
break;
case 11: //wait 4 seconds then turns solenoid #1 off
if(millis() - solenoid_1_Time >= solenoid_1_OffDelay)
stepSolenoid_1 = 99;
break;
case 99:
digitalWrite(solenoid1Pin, LOW);
runSolenoid_1 = LOW;
stepSolenoid_1 = 0;
solenoid_1_done = HIGH;
break;
default:
digitalWrite(solenoid1Pin, LOW);
runSolenoid_1 = LOW;
stepSolenoid_1 = 0;
solenoid_1_done = HIGH;
}
//solenoid #2
switch(stepSolenoid_2){
case 0: //run solenoid #2 cycle
if(runSolenoid_2){
stepSolenoid_2 = 10;
solenoid_2_Time = millis();
}
break;
case 10: //on delay
if (millis() - solenoid_2_Time >= solenoid_2_OnDelay){
stepSolenoid_2 = 20;
}
break;
case 20:
digitalWrite(solenoid2Pin, HIGH);
stepSolenoid_2 = 30;
solenoid_2_Time = millis();
break;
case 30:
if (millis() - solenoid_2_Time >= solenoid_2_OffDelay){
stepSolenoid_2 = 99;
}
break;
case 99:
digitalWrite(solenoid2Pin, LOW);
stepSolenoid_2 = 0;
solenoid_2_Time = millis();
runSolenoid_2 = LOW;
solenoid_2_done = HIGH;
break;
default:
digitalWrite(solenoid2Pin, LOW);
stepSolenoid_2 = 0;
solenoid_2_Time = millis();
runSolenoid_2 = LOW;
solenoid_2_done = HIGH;
}
//solenoid #3
switch(stepSolenoid_3){
case 0: //run solenoid #2 cycle
if(runSolenoid_3){
stepSolenoid_3 = 10;
solenoid_3_Time = millis();
}
break;
case 10: //on delay
if (millis() - solenoid_3_Time >= solenoid_3_OnDelay){
stepSolenoid_3 = 20;
}
break;
case 20:
digitalWrite(solenoid3Pin, HIGH);
stepSolenoid_3 = 30;
solenoid_3_Time = millis();
break;
case 30:
if (millis() - solenoid_3_Time >= solenoid_3_OffDelay){
stepSolenoid_3 = 99;
}
break;
case 99:
digitalWrite(solenoid3Pin, LOW);
stepSolenoid_3 = 0;
solenoid_3_Time = millis();
runSolenoid_3 = LOW;
solenoid_3_done = HIGH;
break;
default:
digitalWrite(solenoid3Pin, LOW);
stepSolenoid_3 = 0;
solenoid_3_Time = millis();
runSolenoid_3 = LOW;
solenoid_3_done = HIGH;
}
if (isCycleRunning && solenoid_1_done && solenoid_2_done && solenoid_3_done){
isCycleRunning = LOW;
solenoid_1_done = LOW;
solenoid_2_done = LOW;
solenoid_3_done = LOW;
}
// save the reading. Next time through the loop,
// it'll be the lastButtonState:
lastButtonState = reading;
}
Always, always, always, make a neat schematic showing all component interconnections.
I should have said one more always.
Haha, have them, but havent wired em yet. Getting close to putting this machine into production and finalizing the build.
Will research and wire tomorrow.
You can reduce / eliminate the risk of wires coming loose by using a something like listed in arduino protoshield screw terminals - Google Search
Oh yeah. Learned the hard way. Was certain I had picutures of the updated wiring but seems I overlooked that. Never again.
Wow, this is way better. Just purchased. Thank you!!
We now have it in writing, subject to a jail term.
Never heard of jst connectors before. Thanks for the introduction.
I was able to draw a diagram of the wiring.
Having trouble figuring out where the pink wire goes? I tested the machine before moving it earlier today and it worked just fine.
From the code it looks like it goes to pin 2, unless there is another pushbutton somewhere.
// pushbutton attached to the pin 2 and to the ground
const int buttonPin = 2; // the number of the pushbutton pin
You need to learn how to draw a proper schematic, rather than a copy/paste and coloured lines.
But good to see you have got your project up and running again.
Tom..
You should learn how to have productive conversations.
I'm a mechanical engineer and a machinist and can't master everything like yourself.
Thank you. I tried pin 2 but for some reason it didn't work. I will test every connection tomorrow and see what I come up with.
Did he say something wrong? You definitely don't know how to draw diagrams, so you need to learn
I did the best I could. This is a 1 time project and should be good enough to show how I connected it.