element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Wireless
  • Technologies
  • More
Wireless
Blog Controlling GPIOs on a BLE module
  • Blog
  • Forum
  • Documents
  • Polls
  • Quiz
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Wireless to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: ndutton
  • Date Created: 15 Jan 2015 9:00 PM Date Created
  • Views 1355 views
  • Likes 1 like
  • Comments 0 comments
  • bluetooth
  • ble
  • bread
  • gpio
  • networks
  • best
  • since
  • thing
  • ackme
  • smart
  • sliced
  • truconnect
Related
Recommended

Controlling GPIOs on a BLE module

ndutton
ndutton
15 Jan 2015
ACKme BLE modules control peripheral devices via GPIOs (General Purpose Input Output devices). GPIO commands and variables enable access to GPIOs, to control and monitor analog functions such as analog-digital converters (ADCs) and PWMs (Pulse Width Modulators). In the case of the ACKme Wahoo evaluation board, peripherals include the tri-color LED, the speaker, user buttons and the thermistor ADC.

Features Demonstrated

  • GPIO commands and variables:
  • get gp u - List GPIO usage, direction and initialization.
    • gfu - Configure GPIO function
    • gdi - Set GPIO direction, for a GPIO functioning as stdio (Standard Input/Output)
    • gge - Get GPIO value, for a GPIO functioning as stdio
    • gse - Set GPIO value, for a GPIO functioning as stdio
  • Controlling LEDs
  • Controlling a speaker
For more on controlling peripherals, see Peripherals.

GPIO Functions and Pins

See Peripherals, GPIO Functions, Defaults and Pins table for the functions and defaults of the Bobcat and Wahoo GPIOs.

Viewing GPIO Usage

To see the current GPIO usage, read the GPIO usage variable. The default Wahoo GPIO usage is:

> get gp u

! # Description

# 0 i2c_sda

# 1 i2c_scl

# 2 user_tx

# 3 none

# 4 none

# 5 user_rx

# 6 none,factory

# 7 reserved

# 8 none

# 9 mode_sel

# 10 status_led

# 11 none

# 12 none

# 13 speaker

# 14 stream_gpio

PWMs

Speakers and LEDs can be controlled with a PWM (Pulse Width Modulator) output. The pwm command provides control of the frequency and duty cycle of a PWM output. PWMs are associated with specific GPIOs.
To use a GPIO as a PWM, any existing function on the GPIO must be de-assigned, with the command gfu <GPIO> none. The the GPIO is set to the pwm function with the command gfu <GPIO> pwm. Then the pwm command assigns the frequency and duty cycle.

LEDs

The example below uses the Wahoo tri-color user LED. This contains a red, green and blue LED, which can be combined to form a wide range of colors:
Wahoo GPIOLED Color
14Red
10Green
11Blue
These same GPIOs are associated with the Wahoo system indicator LEDs, if fitted.
The LEDs can be turned on or off individually by configuring them as output GPIOs, then setting the GPIO level. Note: GPIO 10 (green LED) defaults to the status_led function on Wahoo. It must be de-assigned to none before it can be used for another purpose.
To setup the tri-color LEDs:
TruConnect commandsComments

gfu 10 none

gfu 11 none

gfu 14 none

gfu 10 stdio

gfu 11 stdio

gfu 14 stdio

gdi 10 olo

gdi 11 olo

gdi 14 olo

Free up GPIO 10

Free up GPIO 11

Free up GPIO 14

Assign GPIO 10 to stdio function

Assign GPIO 11 to stdio function

Assign GPIO 14 to stdio function

Set red, green and blue GPIOs to output,

initial level low

Now you can turn on separate red, green and blue leds by setting GPIO values with the gse command. For example:
TruConnect commandsComments

gse 10 0

gse 11 0

gse 14 1

Turn green off

Turn blue off

Turn red on

To set the Wahoo tri-colour LED to a color combining the three LEDs, issue three pwm commands, one for each LED GPIO.
First set each of the LED GPIOs to pwm function with the gfu command:

gfu 10 none

gfu 11 none

gfu 14 none

gfu 10 pwm

gfu 11 pwm

gfu 14 pwm

The ratio of low_count and high_count arguments determines the duty cycle of the PWM, as described in the pwm command documentation. The duty cycle impacts the brightness of the LED, lower duty cycles provide make the LED brighter. The lowest available PWM frequency, about 128Hz, may be used without any detectable flashing of the LED.
For example, to set the named color 'RebeccaPurple':

pwm 14 614 409

pwm 10 818 205

pwm 11 409 614

The Color PWM Table shows the pwm commands for a sample color range.

Speaker

A speaker connected to a GPIO can be controlled with the PWM command or using the beep command.
The Wahoo speaker tone is controlled via GPIO 13 and a PWM. The pwm command documentation describes how to set the frequency and duty cycle of the PWM.
To set the pwm function on GPIO 13:

gfu 13 none

gfu 13 pwm

To play a middle C (C4), the command is:
pwm 13 250 250
To turn the note off:
pwm 13 stop
See the Musical Note PWM Table for pwm commands to play a range of notes on the speaker.
The beep command plays a tone of specified length through a speaker. To use this command, the GPIO wired to the speaker must be set to speaker function with the gfu command.
The following example shows how to set up the Wahoo speaker on GPIO 13 to allow the beep command, assuming GPIO 13 is currently set to another function:

> gfu 13 none

Success

> gfu 13 speaker

Success

> save

Success

> reboot

[COMMAND MODE]

> beep 100

Success

ndutton

  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube