Page 1 of 1

Variabel!

Posted: Mon Nov 05, 2012 7:54 pm
by jgu1
Hi all! :D

I have tried to make a program where I want to enter a value into a variable via a keyboard.

I have tried without success.
Ex. I want to dial 125 in myVar then myVar 125 or (after zeroed Myvar) if I press 53 on the keyboard then myVar 53

First time I press 1 myVar is = 1
second press 2 myVar is = 12
third press 5 myVar is now =125
ect.ect.

is there anyone who has an idea, preferably without using C code.

Thank´s in advance.

Best regard

Jorgen.

Re: Variabel!

Posted: Mon Nov 05, 2012 8:44 pm
by medelec35
Hi jgu1,
Have you tried searching for door lock, as they use a similar method to enter a 3 or 4 digit number then compare it with a stored number to see if correct numbers have been entered.

Martin

Re: Variabel!

Posted: Mon Nov 05, 2012 9:00 pm
by jgu1
Hi Martin!

No, good idea, I would do that if this method is the only way. Thank you Martin :D

Best regard

Jorgen.

Re: Variabel!

Posted: Mon Nov 05, 2012 9:05 pm
by medelec35
your welcome,
If you get stuck I will post something for you.

Martin

Re: Variabel!

Posted: Tue Nov 06, 2012 7:13 am
by Mikat
Hi.
The easy way at short numbers could be like this:
First press
My_var = keyboard * 100
second press
My_var = my_var + (keyboard * 10)
third press
My_var = My_var + keyboard

Or how about an array and pointer?
Like:
Create variables Array_my_var and pointer
Array_my_var[2]
Pointer (byte)
Before first press this
Array_my_var[0] = 0
Array_my_var[1] = 0
Array_my_var[2] = 0
Pointer = 0
Then first press:
Array_my_var[Pointer] = 1
Pointer = Pointer + 1
Then second press:
Array_my_var[Pointer] = 2
Pointer = Pointer + 1
Then third press:
Array_my_var[Pointer] = 5
Pointer = Pointer + 1

Now the Array_my_var is:
Array_my_var[0] = 1
Array_my_var[1] = 2
Array_my_var[2] = 5

Mika

Re: Variabel!

Posted: Tue Nov 06, 2012 10:35 am
by jgu1
Hi Mika! :D

A bit of the same system as Martin described as the combination lock. Thank´s Mika very good explanation. I will test it later today. You will hear from me.

Best regard

Jorgen :o

Re: Variabel!

Posted: Tue Nov 06, 2012 11:00 am
by Dan81
Hello Jorgen

Try this flowchart.
You will have to test if "number" (integer) > 32767

Daniel

Re: Variabel!

Posted: Tue Nov 06, 2012 1:38 pm
by jgu1
Hi Daniel!

EXACTLY just what I need! Thank you wery much. :D


Best regard


Jorgen.. :wink:

Re: Variabel!

Posted: Tue Nov 06, 2012 1:54 pm
by medelec35
Very clever Daniel.
I do like that method.

Martin

Re: Variabel!

Posted: Tue Nov 06, 2012 3:34 pm
by Dan81
Hello

The same with "clear" during typing the number

Daniel

PS:
clear : *
enter : #

Re: Variabel!

Posted: Tue Nov 06, 2012 6:16 pm
by jgu1
Hi Daniel!

Wery nice. It´s also works wery well in real world. Now I will study your flowchart. Thank´s again. :D

Jorgen.

Re: Variabel!

Posted: Tue Nov 06, 2012 6:50 pm
by jgu1
Hi again!

I like this: Number = (Number * 10) + keypad ( and ofcourse the rest) very, simpel easy and clever. :D

Thank´s

Jorgen.