March 16, 2025

Controlling Hardware with Laravel Pinout

Integrate Hardware Control into Your Laravel Applications with Ease​

packages
Controlling Hardware with Laravel Pinout

Ever thought about blending the elegance of Laravel with the tangible world of hardware? Enter Laravel Pinout, a package that bridges this gap, allowing developers to control hardware components directly from their Laravel applications.

What is Laravel Pinout?

Laravel Pinout is a package that enables interaction with hardware components, such as GPIO pins and displays, directly from a Laravel application. This means you can control LEDs, sensors, and even build complex hardware projects using Laravel's expressive syntax.

Key Features

  • GPIO Pin Control: Retrieve and set the state of any GPIO pin, facilitating operations from simple LED toggling to robotic controls.
  • Display Integration: Utilize included drivers to:
    • Display digits on a 7-segment display.
    • Render content on a 16x2 LCD display.
  • Project Possibilities:
    • Smart plug relay.
    • Alarm clock.
    • Weather station.
    • Followers counter.
    • And more...
  • Hardware Compatibility: Supports a wide range of Raspberry Pi models.

Installation

To get started with Laravel Pinout, install the package via Composer:

composer require danjohnson95/pinout

For Laravel versions earlier than 11, add the service provider to your config/app.php file:

'providers' => [ // ... DanJohnson95\Pinout\ServiceProvider::class, // ... ];

Usage Examples

Controlling a Single GPIO Pin

First, import the PinService facade:

use \DanJohnson95\Pinout\Facades\PinService;

Then, interact with a specific GPIO pin:

$pin = PinService::pin(13); // GPIO pin number 13 $pin->turnOn(); // Set the pin to "on" (high) $pin->turnOff(); // Set the pin to "off" (low) $pin->makeInput(); // Set the pin to input mode $pin->makeOutput(); // Set the pin to output mode

Managing Multiple Pins

You can also manage multiple pins simultaneously:

$pins = PinService::pins(13, 19, 26); $pins->turnOn(); // Turn all pins on $pins->turnOff(); // Turn all pins off

Artisan Commands

Laravel Pinout provides Artisan commands for convenience:

  • Get the current state of a pin:

    php artisan pinout:get 13
  • Turn a pin on:

    php artisan pinout:on 13
  • Turn a pin off:

    php artisan pinout:off 13

Conclusion

Laravel Pinout opens up a realm of possibilities by integrating hardware control into Laravel applications. Whether you're building a simple LED indicator or a complex IoT device, Laravel Pinout provides the tools to seamlessly merge software and hardware.

For more details and advanced configurations, refer to the official GitHub repository.

Happy coding and tinkering!

Did you find this article helpful? Share it!