Go Down

Topic: HOW TO CONTROL THE RESET BUTTON OF THE ARDUINO BY PROGRAMMING WITHOUT PRESSING (Read 5325 times) previous topic - next topic

sayam_sethi

Hi!
Need help

I want to create a passcode(buttons/switches) like program in which on typing the passcode the arduino will perform the program. But in case I press a wrong button/switch/digit I should be able to restart the program. Or is there any other way to clear the wrong pressed button/switch/digit.

And in general I would appreciate if someone would be able to tell me how to control the reset or restart(that is what I call it) switch/button. in the sketch/program.

Thanks!

UKHeliBob

Resetting or restarting the Arduino would be using a sledgehammer when a gentle tickle would do.

Can you please provide an example of the program that is causing the problem as there may be many ways to solve it.
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

sayam_sethi

I did not get you first line.........and I want to type a passcode to unlock the program using dtmf decoder and to lock it again. And in case I press the wrong digit, how do I press the backspace key(by pressing #).

PaulS

Quote
and I want to type a passcode to unlock the program using dtmf decoder and to lock it again. And in case I press the wrong digit, how do I press the backspace key(by pressing #).   

Type a passcode using what? If you can type a passcode, why can't you type a backspace?

If you can recognize, in the code you haven't posted, a valid passcode, why can't you recognize a backspace character?
The art of getting good answers lies in asking good questions.

sayam_sethi

Quote
Type a passcode using what? If you can type a passcode, why can't you type a backspace?

If you can recognize, in the code you haven't posted, a valid passcode, why can't you recognize a backspace character?


Well I am thinking of the program as(a,b,c,d are the four binary digits, and the code is 1111):-
Code: [Select]
void loop()
{
if((a==0)&&(b==0)&&(c==0)&&(d==1))
{
if((a==0)&&(b==0)&&(c==0)&&(d==1))
{
if((a==0)&&(b==0)&&(c==0)&&(d==1))
{
if((a==0)&&(b==0)&&(c==0)&&(d==1))
{"my code here"
}
}
}
}
}


My code will only work if I press all the four digits in correct succession.
Any help if the code is wrong and how can I type the 2nd digit again in case I  write it wrong.

And how to restart the program i.e. lock it.

sayam_sethi

Quote
how can I type the 2nd digit again in case I  write it wrong.

I mean any digit

PaulS

Quote
Well I am thinking of the program as(a,b,c,d are the four binary digits, and the code is 1111):-

Well, I'm thinking that that's silly. If a, b, and c are 0, and d is 1, what are the odds that the second if statement will be false? The third? The 4th?

Quote
I mean any digit

You still haven't defined what you are typing these digits on, and you haven't posted any code, so only you can answer that question.

Typically, you'd store all the characters in an array, as they are entered, unless the character is a special character, like enter or backspace. If the character IS enter, you do something with the stored data. If the character IS the backspace, you replace the last character in the array with a NULL and decrement the index.
The art of getting good answers lies in asking good questions.

sayam_sethi

Quote
You still haven't defined what you are typing these digits on, and you haven't posted any code, so only you can answer that question.

Typically, you'd store all the characters in an array, as they are entered, unless the character is a special character, like enter or backspace. If the character IS enter, you do something with the stored data. If the character IS the backspace, you replace the last character in the array with a NULL and decrement the index.


I have told that. I am typing it on a phone and it is being decoded by a dtmf decoder. And I think you have solved my problem partially. Can you also give the code with a little explanation if it is a complex one, since I am a beginner.

AWOL

Code: [Select]
void loop()
{
if((a==0)&&(b==0)&&(c==0)&&(d==1))
{
if((a==0)&&(b==0)&&(c==0)&&(d==1))
{
if((a==0)&&(b==0)&&(c==0)&&(d==1))
{
if((a==0)&&(b==0)&&(c==0)&&(d==1))
{"my code here"
}
}
}
}
}

Code: [Select]

sketch_oct06a.ino: In function 'void loop()':
sketch_oct06a:3: error: 'a' was not declared in this scope
sketch_oct06a:3: error: 'b' was not declared in this scope
sketch_oct06a:3: error: 'c' was not declared in this scope
sketch_oct06a:3: error: 'd' was not declared in this scope
sketch_oct06a:11: error: expected `;' before '}' token


Why don't you post your actual code, and we can help you fix it?

PaulS

Quote
Can you also give the code with a little explanation if it is a complex one, since I am a beginner.

You first. Where is your code?
The art of getting good answers lies in asking good questions.

sayam_sethi

I haven't yet made the code. I need help to make it. Does anyone know a way to secure a  program by a passcode and also lock it.

sayam_sethi

I just want the outline of passcode protecting it. I don't want the entire code.

PaulS

Quote
I haven't yet made the code.

And yet you claim to be getting data from DTMF pulses sent by a phone. Are you, or aren't you?
The art of getting good answers lies in asking good questions.

sayam_sethi

I know how to collect data from dtmf but I dont know how to use it as a passcode

AWOL

Quote
My code will only work if I press all the four digits in correct succession

let me get this straight - the code you haven't written yet behaves like this?

Go Up