Page 1 of 1

How to use multiple buttons in mikroPascal PRO?

Posted: 07 Jun 2010 03:46
by jd2000
I am a new user of mikroPascal PRO, and I have a question: How to detect multiple buttons connected to P0.0, P0.1, P0.2, etc? Your sample code shows how to use one button only, and I don't know how to define the "Button_Pin" if I use several buttons.

Here is you sample code for one button connected to P0.0:

program Button_Test;
var Button_Pin : sbit at P0_0_bit;
var oldstate : bit;

begin
P0 := 255; // configure PORT0 as input
P2 := 0xAA; // initial PORT2 value
oldstate := 0;

while TRUE do
begin
if (Button(1, 0) <> 0) then // detect logical one
oldstate := 1; // update flag
if (oldstate and Button(1, 1)) then // detect one-to-zero transition
begin
P2 := not P2; // invert PORT2
oldstate := 0; // update flag
end;
end;
end.

Re: How to use multiple buttons in mikroPascal PRO?

Posted: 07 Jun 2010 13:23
by slavisa.zlatanovic
Hi!

I have notified our developers about this issue. We'll modify the Button function
so that it has two more parameters (port and pin).

Best regards
Slavisa

Re: How to use multiple buttons in mikroPascal PRO?

Posted: 08 Jun 2010 05:30
by jd2000
OK, thank you. Please let me know when the new program is ready.

Re: How to use multiple buttons in mikroPascal PRO?

Posted: 17 Sep 2010 17:48
by CARLOSPIERETI
Hi. I have seen that you were going to implement new parameters for Button (PORT and time). Is this already implemented? Where can I find this? I am a new user and I realized it is already implemented for MikroPascal PRO for PIC. Are there other new implementations for 8051? My software version is 2.2

Re: How to use multiple buttons in mikroPascal PRO?

Posted: 28 Mar 2014 22:58
by PIERETI
Is it already implemented for MikroPascal PRO for 8051? I have been waiting for this since 2010. I am working with version 3.5 now and it was not implemented.

I have a problem. Every time I have to test an INPUT port state I have to write 1 on it, otherwise I cannot read it.
I know I have to configure the port as INPUT writing 1 on it, but I thought I had to do that only once.

Is there any anser for it? Microcontroller is ATMEL 89S8253.

Thanks,

Carlos