Hi.
I hope one of you can help me with a code, because I am not sure how to begin it and have never tried it before.
I have attached a full overview of my system. I need help for the coding of the arduino; Shortly the system should go from the solarcells where power is generated for the batteries. The solution should be that when you press the button, there is running electricity in the metal at the end for 1 min.
I hope you understand my problem.
Thanks
I do not understand your graph.
However, as I understand your question you want a button to trigger something for a certain amount of time.
Check out the "blink without delay" example in the arduino tutorials. Basically you want something like this:
If (buttonPushed) {
pushTime = currentTime
}
while(currentTime - pushTime < 61 seconds) {
doWhateverYouNeedDoing
}
Hi
Nah, I'm not sure what you mean.
Is this what you want?
const int ledPin = 13;
const int inputPin = 12;
void setup(){
pinMode(ledPin,OUTPUT);
pinMode(inputPin,INPUT);
digitalWrite(inputPin,HIGH); // Enabler pull-up
}
void loop(){
if(digitalRead(inputPin) == LOW){
digitalWrite(ledPin,HIGH);
delay(1000L*60L);
digitalWrite(ledPin,LOW);
}
}
assuming you have other things going on in your sketch, you will want to avoid using the delay function.
The code should be able to:
When the button ("the button that can turn on the electricity on in 60 sec" on drawing) is pressed one time, there should run electricity from the batteries to the two metal objects at the end. The electricity should stop running after 60 sec.
Fletcher Chr: can you explain the sketch since I am new to this?
ok, sounds like you either need a relay or a transistor connected to a digital pin. then you either need to use the code posted above, or my pseudo code to let electricity flow for 60 seconds.
google transistors to figure out how exactly they work, and dont forget to use a common ground.
check the arduino tutorials. what you want to do is very basic, and I believe the very first tutorial already explains everything you need to know to program the delay.