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:
procedure TForm1.FormCreate(Sender: TObject);
begin
Switch:= TGpioLinuxPin.Create(4);
LED.Direction:= gdIn;
Led:= TGpioLinuxPin.Create(18);
Led.Direction:= gdOut;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Led.Value:= true;
Shape1.brush.color:= clLime;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Led.Value:= false;
Shape1.Brush.Color:= clWhite;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
// if Switch.Value = true then Shape2.brush.color:= clRed
// else Shape2.Brush.Color:= clBlue;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
Led.Free;
Switch.Free;
end;
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