Git Product home page Git Product logo

rtk.gpio's Introduction

RTk.GPIO PHP

  • Description: PHP drivers for the Ryanteck RTk.GPIO interface
  • Project Website: GitHub
  • Requirements: An Ubuntu Linux installation or equivalent
  • License: GPL Version 3

Description

The RTk.GPIO is a USB device designed to provide a GPIO interface in the style of a Raspberry Pi to a regular PC and is available from many online retailers including RyanTeck directly.

This library is a driver for the RTk.GPIO for those that prefer (or have a requirement to) use PHP instead of Python.

It has been designed to match the official RPi.GPIO and RTk.GPIO python driver coding interfaces as closely as possible but obviously with PHP syntax.

One of the reasons for its existence is PHP is particularly suited to making web interfaces. This means it's often beneficial to use PHP instead of Python if you require a web interface for your RTk.GPIO.

Included is an LCD driver for the common LCD's on the market as well as a driver for the Noritake GU256x64D-7000 Matrix VFD


Installation instructions

Either Download the latest zip file and extract it, or git clone https://github.com/NeonHorizon/RTk.GPIO.git

The project contains the following files...

  • PHP_GPIO/RTk.GPIO.php - this is the main driver (the file you need for your own projects)
  • PHP_GPIO/Hitachi.LCD.php - this is a Hitachi LCD driver (such as the common 16x2 LCDs) which can be used with RTk.GPIO
  • PHP_GPIO/Noritake.VFD.php - this is a driver for the Noritake GU256x64D-7000 VFD which can be used with RTk.GPIO
  • gpio_examples - A script with some examples of how to use the RTk.GPIO driver
  • lcd_examples - A script with some examples of how to use the Hitachi.LCD driver
  • vfd_examples - A script with some examples of how to use the Noritake.VFD driver
  • gpio_random_output - An example script that changes all the GPIO's to outputs and randomly blinks them
  • gpio_read_all - An example script that changes all the GPIO's to inputs and notifies when they go high or low
  • gpio_brutal_test - A script that brutally tests the RTk.GPIO by randomly changing the GPIO pin settings and reading/writing to them
  • README.md - This file
  • COPYING.txt - The GPLv3 license

Presumably you already have PHP installed but if you don't install it:

Current Ubuntu:

sudo apt -y install php-cli

Quick Start

The easiest way to make a start is to take a look at the examples file which was part of your download. This includes descriptions of most of the commands you can perform. You can test this script directly by plugging your RTk.GPIO into your computer (with nothing connected to the GPIO) and running the examples file from inside the directory:

cd RTk.GPIO
./examples

Using the Driver

Using the driver in your own scripts is fairly simple...

If you want to run your script directly from the command line it must start by telling Linux it's PHP and then include the php opening tag:

#!/usr/bin/php
<?php

Now we are in the PHP code; load the RTk.GPIO driver and tell it you want to use it by the name GPIO:

require_once('PHP_GPIO/RTk.GPIO.php');
use PHP_GPIO\RTK\GPIO as GPIO;

Open a serial connection to your RTk.GPIO and call it $GPIO (see the examples file of how to use multiple RTk.GPIO's):

$GPIO = new GPIO();

Specify the pin numbering scheme:

$GPIO->setmode(GPIO::BCM);

Send your first commands!

For example here we set pin 4 to be an output and set it high:

$GPIO->setup(4, GPIO::OUT);
$GPIO->output(4, GPIO::HIGH);

License Information

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

rtk.gpio's People

Contributors

neonhorizon avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

wire54321

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.