Platforms to show: All Mac Windows Linux Cross-Platform
Back to WiringPiMBS module.
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
Returns true on success or false on failure.
LoadError is set in case of failure.
See also:
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | WiringPi | MBS Linux Plugin | 15.3 | ❌ No | ❌ No | ✅ Yes | ❌ No | Desktop, Console & Web |
It returns an unsigned 32-bit number which wraps after approximately 71 minutes.
Some examples using this method:
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | WiringPi | MBS Linux Plugin | 15.3 | ❌ No | ❌ No | ✅ Yes | ❌ No | Desktop, Console & Web |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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:
The items on this page are in the following plugins: MBS Linux Plugin.
