Platforms to show: All Mac Windows Linux Cross-Platform

Back to WiringPiMBS module.

Next items

WiringPiMBS.analogRead(pin as Integer) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
This returns the value read on the supplied analog input pin.

You will need to register additional analog modules to enable this function for devices such as the Gertboard, quick2Wire analog board, etc.

WiringPiMBS.analogWrite(pin as Integer, value as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
This writes the given value to the supplied analog pin.

You will need to register additional analog modules to enable this function for devices such as the Gertboard.

WiringPiMBS.delay(HowLong as UInt32)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
This causes program execution to pause for at least howLong milliseconds.

Due to the multi-tasking nature of Linux it could be longer. Note that the maximum delay is an unsigned 32-bit integer or approximately 49 days.

WiringPiMBS.delayMicroseconds(HowLong as UInt32)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
This causes program execution to pause for at least howLong microseconds.

Due to the multi-tasking nature of Linux it could be longer. Note that the maximum delay is an unsigned 32-bit integer microseconds or approximately 71 minutes.

Delays under 100 microseconds are timed using a hard-coded loop continually polling the system time, Delays over 100 microseconds are done using the system nanosleep() function – You may need to consider the implications of very short delays on the overall performance of the system, especially if using threads.

WiringPiMBS.digitalRead(pin as Integer) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
This function returns the value read at the given pin.

It will be kHIGH or kLOW (1 or 0) depending on the logic level at the pin.

WiringPiMBS.digitalWrite(pin as Integer, value as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
Writes the value kHIGH or kLOW (1 or 0) to the given pin which must have been previously set as an output.

WiringPi treats any non-zero number as kHIGH, however 0 is the only representation of kLOW.

WiringPiMBS.digitalWriteByte(value as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
This writes the 8-bit byte supplied to the first 8 GPIO pins.

It’s the fastest way to set all 8 bits at once to a particular value, although it still takes two write operations to the Pi’s GPIO hardware.

WiringPiMBS.gpioClockSet(pin as Integer, value as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
Sets the clock.

WiringPiMBS.I2CRead(fd as Integer) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
Simple device read.

Some devices present data when you read them without having to do any register transactions.
If the return value is negative then an error has happened and you should consult errno.

WiringPiMBS.I2CReadReg16(fd as Integer, reg as Integer) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
Simple device read.

Some devices present data when you read them without having to do any register transactions.
Read a 16-bit value from the device register indicated.

If the return value is negative then an error has happened and you should consult errno.

WiringPiMBS.I2CReadReg8(fd as Integer, reg as Integer) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
Simple device read.

Some devices present data when you read them without having to do any register transactions.
Read an 8-bit value from the device register indicated.

If the return value is negative then an error has happened and you should consult errno.

WiringPiMBS.I2CSetup(devId as Integer) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
This initialises the I2C system with your given device identifier.

The ID is the I2C number of the device and you can use the i2cdetect program to find this out. I2CSetup() will work out which revision Raspberry Pi you have and open the appropriate device in /dev.

The return value is the standard Linux filehandle, or -1 if any error – in which case, you can consult errno as usual.

E.g. the popular MCP23017 GPIO expander is usually device Id 0x20, so this is the number you would pass into wiringPiI2CSetup().

WiringPiMBS.I2CSetupInterface(device as string, devId as Integer) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
This initialises the I2C system with your given device identifier and name.

WiringPiMBS.I2CWrite(fd as Integer, Data as Integer) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
Simple device write.

Some devices accept data this way without needing to access any internal registers.
If the return value is negative then an error has happened and you should consult errno.

WiringPiMBS.I2CWriteReg16(fd as Integer, reg as Integer, Data as Integer) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
Simple device write.

Some devices accept data this way without needing to access any internal registers.
Write a 16-bit data value into the device register indicated.

If the return value is negative then an error has happened and you should consult errno.

WiringPiMBS.I2CWriteReg8(fd as Integer, reg as Integer, Data as Integer) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
Simple device write.

Some devices accept data this way without needing to access any internal registers.
Write a 8-bit data value into the device register indicated.

If the return value is negative then an error has happened and you should consult errno.

WiringPiMBS.LoadLibrary(File as FolderItem) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
Loads the library.

Returns true on success or false on failure.
LoadError is set in case of failure.

See also:

WiringPiMBS.LoadLibrary(Path as string) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
Loads the library.

Returns true on success or false on failure.
LoadError is set in case of failure.

See also:

WiringPiMBS.micros as UInt32

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
This returns a number representing the number of microseconds since your program called one of the wiringPiSetup functions.

It returns an unsigned 32-bit number which wraps after approximately 71 minutes.

Some examples using this method:

WiringPiMBS.millis as UInt32

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
This returns a number representing the number of milliseconds since your program called one of the wiringPiSetup functions.

It returns an unsigned 32-bit number which wraps after 49 days.

Some examples using this method:

WiringPiMBS.physPinToGpio(physPin as Integer) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
This returns the BCM_GPIO pin number of the supplied physical pin on the P1 connector.

WiringPiMBS.piBoardId(byref model as Integer, byref Rev as Integer, byref Mem as Integer, byref Maker as Integer, byref OverVolted as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
Queries board identifiers.

Mem is memory in Megabytes.
Maker, Model and Rev are value which match the constants in this module.

Some examples using this method:

WiringPiMBS.piBoardRev as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
This returns the board revision of the Raspberry Pi.

It will be either 1 or 2. Some of the BCM_GPIO pins changed number and function when moving from board revision 1 to 2, so if you are using BCM_GPIO pin numbers, then you need to be aware of the differences.

Some examples using this method:

WiringPiMBS.piHiPri(pri as Integer) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
This attempts to shift your program (or thread in a multi-threaded program) to a higher priority and enables a real-time scheduling.

The priority parameter should be from 0 (the default) to 99 (the maximum). This won’t make your program go any faster, but it will give it a bigger slice of time when other programs are running. The priority parameter works relative to others – so you can make one program priority 1 and another priority 2 and it will have the same effect as setting one to 10 and the other to 90 (as long as no other programs are running with elevated priorities)

The return value is 0 for success and -1 for error. If an error is returned, the program should then consult the errno global variable, as per the usual conventions.

Note: Only programs running as root can change their priority. If called from a non-root program then nothing happens.

WiringPiMBS.piLock(Key as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
Locks a synchronization lock.

These allow you to synchronise variable updates from your main program to any threads running in your program. keyNum is a number from 0 to 3 and represents a “key”. When another process tries to lock the same key, it will be stalled until the first process has unlocked the same key.

You may need to use these functions to ensure that you get valid data when exchanging data between your main program and a thread – otherwise it’s possible that the thread could wake-up halfway during your data copy and change the data – so the data you end up copying is incomplete, or invalid.

WiringPiMBS.piMakerNames(index as Integer) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
Maps maker numbers to names.

Some examples using this method:

WiringPiMBS.piModelNames(index as Integer) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
Maps model numbers to names.

Some examples using this method:

WiringPiMBS.pinMode(pin as Integer, mode as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
This sets the mode of a pin to either INPUT, OUTPUT, PWM_OUTPUT or GPIO_CLOCK.

Note that only wiringPi pin 1 (BCM_GPIO 18) supports PWM output and only wiringPi pin 7 (BCM_GPIO 4) supports CLOCK output modes.

This function has no effect when in Sys mode. If you need to change the pin mode, then you can do it with the gpio program in a script before you start your program.

WiringPiMBS.piRevisionNames(index as Integer) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
Maps revision numbers to names.

Some examples using this method:

WiringPiMBS.piUnlock(Key as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
Unlocks a synchronization lock.

These allow you to synchronise variable updates from your main program to any threads running in your program. keyNum is a number from 0 to 3 and represents a “key”. When another process tries to lock the same key, it will be stalled until the first process has unlocked the same key.

You may need to use these functions to ensure that you get valid data when exchanging data between your main program and a thread – otherwise it’s possible that the thread could wake-up halfway during your data copy and change the data – so the data you end up copying is incomplete, or invalid.

WiringPiMBS.pullUpDnControl(pin as Integer, pud as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
This sets the pull-up or pull-down resistor mode on the given pin, which should be set as an input.

Unlike the Arduino, the BCM2835 has both pull-up an down internal resistors. The parameter pud should be; kPUD_OFF, (no pull up/down), kPUD_DOWN (pull to ground) or kPUD_UP (pull to 3.3v) The internal pull up/down resistors have a value of approximately 50KΩ on the Raspberry Pi.

This function has no effect on the Raspberry Pi’s GPIO pins when in Sys mode. If you need to activate a pull-up/pull-down, then you can do it with the gpio program in a script before you start your program.

WiringPiMBS.pwmSetClock(divisor as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
This sets the divisor for the PWM clock.

WiringPiMBS.pwmSetMode(mode as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
The PWM generator can run in 2 modes – “balanced” and “mark:space”.

The mark:space mode is traditional, however the default mode in the Pi is “balanced”. You can switch modes by supplying the parameter: kPWM_MODE_BAL or kPWM_MODE_MS.

WiringPiMBS.pwmSetRange(range as UInt32)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
This sets the range register in the PWM generator.

The default is 1024.

WiringPiMBS.pwmToneWrite(pin as Integer, value as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
Writes a tone.

WiringPiMBS.pwmWrite(pin as Integer, value as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
Writes the value to the PWM register for the given pin.

The Raspberry Pi has one on-board PWM pin, pin 1 (BMC_GPIO 18, Phys 12) and the range is 0-1024. Other PWM devices may have other PWM ranges.

This function is not able to control the Pi’s on-board PWM when in Sys mode.

WiringPiMBS.Read(fd as Integer, count as UInt64) as Memoryblock

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
Read attempts to read count bytes of data from the object referenced by the descriptor fildes into a buffer.

Returns the memoryblock on success (if we got more than zero bytes).
Errno is set in case of error.

WiringPiMBS.serialClose(fd as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
Closes the device identified by the file descriptor given.

WiringPiMBS.serialDataAvail(fd as Integer) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
Returns the number of characters available for reading, or -1 for any error condition, in which case errno will be set appropriately.

WiringPiMBS.serialFlush(fd as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
This discards all data received, or waiting to be send down the given device.

WiringPiMBS.serialGetchar(fd as Integer) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
Returns the next character available on the serial device.

This call will block for up to 10 seconds if no data is available (when it will return -1)

WiringPiMBS.serialOpen(device as String, Baud as Integer) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
This opens and initialises the serial device and sets the baud rate.

It sets the port into “raw” mode (character at a time and no translations), and sets the read timeout to 10 seconds. The return value is the file descriptor or -1 for any error, in which case errno will be set as appropriate.

WiringPiMBS.serialPutchar(fd as Integer, c as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
Sends the single byte to the serial device identified by the given file descriptor.

WiringPiMBS.serialPutData(fd as Integer, data as Memoryblock)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
Sends the nul-terminated string to the serial device identified by the given file descriptor.

This sends text with any encoding.

WiringPiMBS.serialPuts(fd as Integer, text as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
Sends the nul-terminated string to the serial device identified by the given file descriptor.

This sends text with UTF-8 encoding.

WiringPiMBS.setPadDrive(group as Integer, value as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
This sets the “strength” of the pad drivers for a particular group of pins.

There are 3 groups of pins and the drive strength is from 0 to 7. Do not use this unless you know what you are doing.

WiringPiMBS.SPIDataRW(channel as Integer, data as Memoryblock) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
This performs a simultaneous write/read transaction over the selected SPI bus.

Data that was in your buffer is overwritten by data returned from the SPI bus.

That’s all there is in the helper library. It is possible to do simple read and writes over the SPI bus using the standard read() and write() system calls though – write() may be better to use for sending data to chains of shift registers, or those LED strings where you send RGB triplets of data. Devices such as A/D and D/A converters usually need to perform a concurrent write/read transaction to work.

WiringPiMBS.SPIGetFd(channel as Integer) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
Queries the file descriptor for a channel.

WiringPiMBS.SPISetup(channel as Integer, speed as Integer) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method WiringPi MBS Linux Plugin 15.3 ❌ No ❌ No ✅ Yes ❌ No Desktop, Console & Web
This is the way to initialise a channel (The Pi has 2 channels; 0 and 1).

The speed parameter is an integer in the range 500,000 through 32,000,000 and represents the SPI clock speed in Hz.

The returned value is the Linux file-descriptor for the device, or -1 on error. If an error has happened, you may use the standard errno global variable to see why.

Some examples using this method:

Next items

The items on this page are in the following plugins: MBS Linux Plugin.


The biggest plugin in space...