View on GitHub

SmallBasicPIGPIO

Plugin for SmallBASIC to access GPIO pins on a Raspberry PI

back to main page

Basic GPIO Commands

GPIO_SetInput

GPIO_SetInput(PinNumber)

PinNumber = 0 … 53

Sets GPIO pin PinNumber as an input. The internal pullup-resistor will be set automaticly. Before using a GPIO pin, you should use either GPIOSetInput or GPIOSetOutput.

GPIO_SetOutput

GPIO_SetOutput(PinNumber)

PinNumber = 0 … 53

Sets GPIO pin PinNumber as an output. Before using a GPIO pin, you should use either GPIOSetInput or GPIOSetOutput.

GPIO_Write

GPIO_Write(Pin, Level)

Pin = 0 … 53
Level = 0 or 1

If Pin is configured as output, the voltage Level can be set to ground (low) or +3.3V (high).

GPIO_Write(4, 0)   'Sets pin 4 to low (ground)
GPIO_Write(4, 1)   'Sets pin 4 to high (+3.3V)

GPIO_Read

Status = GPIO_Read(Pin)

Pin = 0 … 53
Status = 0 or 1

If Pin is configured as input, the voltage Level can be read. If the Pin is at ground (low), Status will be 1. If the Pin is at +3.3V (high) Status will be 0.

Status = GPIO_Read(4)   'Reads the voltage level of pin 4

GPIO_Trigger

GPIO_Trigger(Pin, Duration, Level)

Pin = 0 … 53
Duration = 1 … 100
Level = 0 or 1

If Pin is configured as output, a trigger pulse at Pin will be emitted with a Duration in microseconds and a Level of low or high.

GPIO_Trigger(4, 50, 1)  'A 50 µs Trigger pulse at pin 4 with +3.3V (high)

GPIO_Pwm

GPIO_Pwm(Pin, PWMLevel)

Pin = 0 … 53
PWMLevel = 0 … 255

If Pin is configured as output, a PWM-signal (Pules Width Modulation) will be emitted to Pin with a duty cycle of PWMLevel. PWMLevel can be a value from 0 to 255.

GPIO_Pwm(4, 128)  'Sets PWM with a duty cycle of 50% to pin 4

GPIO_Initialise - Experts

GPIO_Initialise()

When importing the plugin, gpio access will be automatically initialized. If you want to manually initialize gpio access, use this function. Useful if you terminated the access manually with gpio_terminate().

GPIO_Terminate - Experts

GPIO_Terminate()

When closing a SmallBASIC program, gpio access will be automatically terminated. If you want to manually terminate gpio access, use this function.


back to main page