How to use multiple buttons in mikroPascal PRO?

General discussion on mikroPascal PRO for 8051.
Post Reply
Author
Message
jd2000
Posts: 4
Joined: 07 Jun 2010 03:29

How to use multiple buttons in mikroPascal PRO?

#1 Post by jd2000 » 07 Jun 2010 03:46

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.

User avatar
slavisa.zlatanovic
mikroElektronika team
Posts: 1321
Joined: 07 Apr 2009 09:39

Re: How to use multiple buttons in mikroPascal PRO?

#2 Post by slavisa.zlatanovic » 07 Jun 2010 13:23

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
Best regards
Slavisa

jd2000
Posts: 4
Joined: 07 Jun 2010 03:29

Re: How to use multiple buttons in mikroPascal PRO?

#3 Post by jd2000 » 08 Jun 2010 05:30

OK, thank you. Please let me know when the new program is ready.

CARLOSPIERETI
Posts: 1
Joined: 17 Sep 2010 17:41

Re: How to use multiple buttons in mikroPascal PRO?

#4 Post by CARLOSPIERETI » 17 Sep 2010 17:48

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

PIERETI
Posts: 3
Joined: 31 Jan 2014 21:15

Re: How to use multiple buttons in mikroPascal PRO?

#5 Post by PIERETI » 28 Mar 2014 22:58

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

Post Reply

Return to “mikroPascal PRO for 8051 General”