Recent

Author Topic: (Solved)Pascalio/GPio access on a Raspberry Pi, again.  (Read 238 times)

MadMike

  • New Member
  • *
  • Posts: 16
(Solved)Pascalio/GPio access on a Raspberry Pi, again.
« on: October 22, 2020, 01:51:03 pm »
Hi,

Hopefully this won't take up much of your time. I'm a complete noob at this software stuff. Much more at home with a few chips and a reel of solder.

I'm trying to use the GPIO on a Raspberry to address some external hardware and then read the state of this hardware on another GPIO.

I've successfully used the FGPIO unit from Pascalio to individually write OR read to a SINGLE pin. That's fine.

But this below doesn't work:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. begin
  3.   Switch:= TGpioLinuxPin.Create(4);
  4.   LED.Direction:= gdIn;
  5.  
  6.   Led:= TGpioLinuxPin.Create(18);
  7.   Led.Direction:= gdOut;
  8. end;
  9.  
  10. procedure TForm1.Button1Click(Sender: TObject);
  11. begin
  12.   Led.Value:= true;
  13.   Shape1.brush.color:= clLime;
  14. end;
  15.  
  16. procedure TForm1.Button2Click(Sender: TObject);
  17. begin
  18.   Led.Value:= false;
  19.   Shape1.Brush.Color:= clWhite;
  20. end;
  21.  
  22. procedure TForm1.Button3Click(Sender: TObject);
  23. begin
  24. //  if Switch.Value = true then Shape2.brush.color:= clRed
  25.  // else Shape2.Brush.Color:= clBlue;
  26. end;
  27.  
  28. procedure TForm1.FormDestroy(Sender: TObject);
  29. begin
  30.   Led.Free;
  31.   Switch.Free;
  32. end;
  33.  
  34. end.

I've since realised that the second 'create' overwrites the first instance.

My question is how can I initialise many pins at once?

This was most useful at first, and seems to indicate I may need to pin the needed GPIO's in an array somehow:

https://techpluscode.de/running-lights-and-led-control-with-lazarus/

All answers gratefully received.

Mike

« Last Edit: October 22, 2020, 03:44:45 pm by MadMike »

MadMike

  • New Member
  • *
  • Posts: 16
Re: Pascalio/GPio access on a Raspberry Pi, again.
« Reply #1 on: October 22, 2020, 03:29:43 pm »
Sorry fellas,

Just noticed the typo.

Works now...

Doh!

 

TinyPortal © 2005-2018