Datasheet
485
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroPASCAL PRO for AVR
CHAPTER 6
Example
On every PORTB0 one-to-zero transition PORTC is inverted :
program Button_Test;
// Button connections
var Button_Pin : sbit at PINB.B0; // Input pin, PINx register
is used
var Button_Pin_Direction : sbit at DDRB.B0;
// End Button connections
var oldstate : bit;
begin
Button_Pin_Direction := 0; // Set Button pin as input
DDRC := 0xFF; // Configure PORTC as output
PORTC := 0xAA; // Initial PORTC value
oldstate := 0; // oldstate initial value
while TRUE do
begin
if (Button(1, 1) <> 0) then // Detect logical one
oldstate := 1; // Update flag
if (oldstate and Button(1, 0)) then // Detect one-to-zero
transition
begin
PORTC := not PORTC; // Invert PORTC
oldstate := 0; // Update flag
end;
end; // Endless loop
end.