Application Examples

On this page you can find some simple applications with Pascalite Microcontrollers. If you have done an interesting project with Pascalite and would like to have it published on these pages, please contact us!

  • Keyboard
  • DTMF-decoder
Keyboard

With this schematic and program a 12-key keyboard can be attached to any Pascalite Microcontroller, using only one analog input.

Keyboard

This programs continuously reads the keyboard, and displays the selected values on the LCD-module:

program keyboard;

const an_key = 1;

var key : byte;

procedure init;
begin
   { clear LCD }
   write(lcd,255);

   { decode table }
   mem[0,0]:=42;    { '*' }
   mem[0,1]:=55;    { '7' }
   mem[0,2]:=52;    { '4' }
   mem[0,3]:=49;    { '1' }
   mem[0,4]:=48;    { '0' }
   mem[0,5]:=56;    { '8' }
   mem[0,6]:=53;    { '5' }
   mem[0,7]:=50;    { '2' }
   mem[0,8]:=35;    { '#' }
   mem[0,9]:=57;    { '9' }
   mem[0,10]:=54;   { '6' }
   mem[0,11]:=51;   { '3' }
end;

procedure run;
begin
  repeat
    analog(an_key, key); { measure analog input }
  until key>10;          { until a key is pressed }

  key:=key-10;     { get keycode from table }
  key:=key DIV 21; { divide voltage by 21 }
  key:=mem[0,key]; { get corresponding key code }
  write(lcd,key);

  repeat
    analog(an_key, key);
  until key<10;         

{ wait until key is released }
end;

{ Main }
begin
  init;      { clear display and store table }
  repeat
    run;     { endless loop }
  until 0=1;
end.
Keyboard12
DTMF-decoder

With this schematic a DTMF-decoder can be attached to a Pascalite Plus Microcontroller, using 5 digital I/O-lines.

DTMF

This programs continuously reads data from the DTMF-decoder, and displaysthe data on a LCD-module:

program DTMF_decoder;

const data_valid = d4;

var x : byte;

procedure init;
begin
  { store decode-table in eeprom }
  mem[0,15]:=67;
  mem[0,14]:=55;
  mem[0,13]:=42;
  mem[0,12]:=51;
  mem[0,11]:=65;
  mem[0,10]:=53;
  mem[0,9]:=57;
  mem[0,8]:=49;
  mem[0,7]:=66;
  mem[0,6]:=54;
  mem[0,5]:=48;
  mem[0,4]:=50;
  mem[0,3]:=35;
  mem[0,2]:=52;
  mem[0,1]:=56;
  mem[0,0]:=68;

  { clear display }
  write(lcd,255);
end;

procedure process;
begin
  { only the 4 lower bits are important (d0..d3) }
  x:=x mod 16;
  { read ASCII-value from table }
  x:=mem[0,x];
  { write result to lcd and rs232 }
  write(lcd,x);
  write(rs232,x);
end;

procedure run;
begin
  repeat
  until data_valid;      { wait for data_valid }
  read(portd, x);
  process; { read data }
  repeat
  until not(data_valid); { wait until not(data_valid) }
end;

{ Main }
begin
  init;
  repeat
    run;
  until 0=1; { endless loop }
end.