{"id":2504,"date":"2024-04-30T16:54:08","date_gmt":"2024-04-30T16:54:08","guid":{"rendered":"https:\/\/blog.embeddedexpert.io\/?p=2504"},"modified":"2024-04-30T16:54:11","modified_gmt":"2024-04-30T16:54:11","slug":"getting-started-with-stm32wb55-multiple-led-control-using-ble","status":"publish","type":"post","link":"https:\/\/blog.embeddedexpert.io\/?p=2504","title":{"rendered":"Getting Started with STM32WB55: Multiple LED Control using BLE"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1015\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/04\/Screenshot-2024-03-22-at-7.07.10\u202fAM-1-2-2-1024x1015.png\" alt=\"\" class=\"wp-image-2505\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/04\/Screenshot-2024-03-22-at-7.07.10\u202fAM-1-2-2-1024x1015.png 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/04\/Screenshot-2024-03-22-at-7.07.10\u202fAM-1-2-2-300x297.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/04\/Screenshot-2024-03-22-at-7.07.10\u202fAM-1-2-2-150x150.png 150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/04\/Screenshot-2024-03-22-at-7.07.10\u202fAM-1-2-2-768x761.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/04\/Screenshot-2024-03-22-at-7.07.10\u202fAM-1-2-2-750x743.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/04\/Screenshot-2024-03-22-at-7.07.10\u202fAM-1-2-2-400x396.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/04\/Screenshot-2024-03-22-at-7.07.10\u202fAM-1-2-2-250x248.png 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/04\/Screenshot-2024-03-22-at-7.07.10\u202fAM-1-2-2.png 1130w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>In the previous guide (<a rel=\"noreferrer noopener\" href=\"https:\/\/blog.embeddedexpert.io\/?p=2491\" target=\"_blank\">here<\/a>), we took a look how to configure the service to accept data from the smartphone to control single LED. <\/p>\n\n\n\n<p>In this guide, we shall extend the service to accept multiple data to control multiple LEDs.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>In this guide, we shall cover the following:<\/p>\n\n\n\n<p><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Service modification.<\/li><li>LED control.<\/li><li>Results.<\/li><\/ul>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. Service Modification<\/h2>\n\n\n\n<p>Continue from the previous guide, Open the ioc file within STM32CubeIDE project.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"572\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/04\/2024-04-30_19-36-19-1024x572.jpg\" alt=\"\" class=\"wp-image-2506\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/04\/2024-04-30_19-36-19-1024x572.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/04\/2024-04-30_19-36-19-300x167.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/04\/2024-04-30_19-36-19-768x429.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/04\/2024-04-30_19-36-19-1536x857.jpg 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/04\/2024-04-30_19-36-19-2048x1143.jpg 2048w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/04\/2024-04-30_19-36-19-1150x642.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/04\/2024-04-30_19-36-19-750x419.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/04\/2024-04-30_19-36-19-400x223.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/04\/2024-04-30_19-36-19-250x141.jpg 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>From STM32_WPAN, select the LEDControl Service, set the Value length to 2 and keep the rest of the settings from the pervious guide.<\/p>\n\n\n\n<p>Save the project and this will generate the project.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. LED Control:<\/h2>\n\n\n\n<p>Now, open custom_stm.c source file as following:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"268\" height=\"1024\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/04\/2024-04-27_07-06-24-268x1024.jpg\" alt=\"\" class=\"wp-image-2494\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/04\/2024-04-27_07-06-24-268x1024.jpg 268w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/04\/2024-04-27_07-06-24-250x954.jpg 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/04\/2024-04-27_07-06-24.jpg 542w\" sizes=\"(max-width: 268px) 100vw, 268px\" \/><\/figure><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>In the line: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">\/* USER CODE BEGIN CUSTOM_STM_Service_1_Char_1_ACI_GATT_ATTRIBUTE_MODIFIED_VSEVT_CODE *\/<\/pre><\/div>\n\n\n\n<p>Add the following to control the LEDs as following:<\/p>\n\n\n\n<p><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">uint8_t LED_Number=attribute_modified-&gt;Attr_Data[0];\nuint8_t state=attribute_modified-&gt;Attr_Data[1];\nswitch (LED_Number)\n{\n  case 0: HAL_GPIO_WritePin(LD1_GPIO_Port, LD1_Pin, state); break;\n  case 1: HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, state);break;\n  case 2: HAL_GPIO_WritePin(LD3_GPIO_Port, LD3_Pin, state);break;\n\n  default:break;\n}<\/pre><\/div>\n\n\n\n<p>Thats all for the LED control.<\/p>\n\n\n\n<p>Save the project, build the project and run it on your STM32WB55-Nucleo.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. Results:<\/h2>\n\n\n\n<p><\/p>\n\n\n\n<p>Using LightBlue, connect to the WB55_EExp:<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Multiple LED control using BLE on STM32WB55\" width=\"1170\" height=\"658\" src=\"https:\/\/www.youtube.com\/embed\/W_m7BgQtYTc?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>Happy coding \ud83d\ude09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the previous guide (here), we took a look how to configure the service to accept data from the smartphone to control single LED. In this guide, we shall extend the service to accept multiple data to control multiple LEDs. In this guide, we shall cover the following: Service modification. LED control. Results. 1. Service [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,11,12],"tags":[],"class_list":["post-2504","post","type-post","status-publish","format-standard","hentry","category-embedded-systems","category-peripheral-drivers","category-stm32"],"_links":{"self":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/2504"}],"collection":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2504"}],"version-history":[{"count":1,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/2504\/revisions"}],"predecessor-version":[{"id":2507,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/2504\/revisions\/2507"}],"wp:attachment":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2504"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2504"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2504"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}