{"id":11673,"date":"2022-09-12T04:22:55","date_gmt":"2022-09-12T04:22:55","guid":{"rendered":"http:\/\/fastbitlab.com\/?p=11673"},"modified":"2023-08-25T15:47:05","modified_gmt":"2023-08-25T10:17:05","slug":"coding-to-turn-on-an-led","status":"publish","type":"post","link":"https:\/\/fastbitlab.com\/blog\/coding-to-turn-on-an-led\/","title":{"rendered":"Microcontroller Embedded C Programming Lecture 104| Coding to Turn on an LED"},"content":{"rendered":"<div class=\"boldgrid-section\" style=\"background-image: linear-gradient(to left, #eeeeee, #eeeeee);\" data-bg-color-1=\"#EEEEEE\" data-bg-color-2=\"#EEEEEE\" data-bg-direction=\"to left\">\n<div class=\"container\">\n<div class=\"row\" style=\"padding-top: 35px; padding-bottom: 0px; background-image: linear-gradient(to left, #eeeeee, #eeeeee);\" data-bg-color-1=\"#EEEEEE\" data-bg-color-2=\"#EEEEEE\" data-bg-direction=\"to left\">\n<div class=\"col-md-1 col-sm-12 col-xs-12 col-lg-1\">\n<div class=\"boldgrid-shortcode\" data-imhwpb-draggable=\"true\">\n\n<\/div>\n<p class=\"\">&nbsp;<\/p>\n<\/div>\n<div class=\"col-md-10 col-sm-12 col-xs-12 col-lg-10\">\n<h1 class=\"color-4-text-contrast color4-background-color\" style=\"text-align: center; font-size: 30px; border-width: 0px; line-height: 50px;\"><span style=\"color: #000080;\"><strong>Coding to Turn on an LED<\/strong><\/span><\/h1>\n<div class=\"row bg-editor-hr-wrap\" style=\"border-width: 0px; margin-top: -25px;\">\n<div class=\"col-lg-12 col-md-12 col-xs-12 col-sm-12\">\n<div>\n<p>&nbsp;<\/p>\n<div class=\"bg-hr bg-hr-10 color2-color\" style=\"border-style: solid; border-width: 0px 0px 3px;\"><\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 25px; line-height: 35px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"text-decoration: underline; color: #000080;\"><b>Exercise:<\/b><\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Write a program to turn on the LED of your target board.<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">For this exercise, we need the knowledge of&nbsp;<\/span><\/p>\n<ul class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #ff6600;\"><a style=\"color: #ff6600;\" href=\"http:\/\/fastbitlab.com\/pointers-in-c\/\" target=\"_blank\" rel=\"noopener\">pointers<\/a>&nbsp;<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"color: #ff6600;\"><a style=\"color: #ff6600;\" href=\"http:\/\/fastbitlab.com\/bitwise-operators-in-c\/\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">bitwise operators&nbsp;<\/span><\/a><\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #ff6600;\">Hardware connections<\/span><\/li>\n<\/ul>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 25px; line-height: 40px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"text-decoration: underline; color: #000080;\"><b>Hardware connections<\/b><\/span><\/p>\n<ul class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">Let&#8217;s understand how external hardware(LED) is connected to the microcontroller.&nbsp;<\/span><\/li>\n<\/ul>\n<ul class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">For this, we have to refer to the schematic of the board you are using.&nbsp;<\/span><\/li>\n<\/ul>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Let&#8217;s go to ST&#8217;s documentation&#8217;s resource section, download the schematic, and then analyze it.<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Let&#8217;s refer to the online documentation of the STM32F4DISCOVERY board, which is there on the ST&#8217;s website.<\/span><\/p>\n<figure id=\"attachment_11676\" aria-describedby=\"caption-attachment-11676\" style=\"width: 674px\" class=\"wp-caption aligncenter\"><img fetchpriority=\"high\" decoding=\"async\" class=\"wp-image-11676 \" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/09\/Figure-1-7-1024x548.png\" alt=\"Figure 1. ST website\" width=\"674\" height=\"361\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-1-7-1024x548.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-1-7-300x161.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-1-7-768x411.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-1-7-600x321.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-1-7-1536x822.png 1536w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-1-7-200x107.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-1-7-400x214.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-1-7-800x428.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-1-7-1200x642.png 1200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-1-7.png 1897w\" sizes=\"(max-width: 674px) 100vw, 674px\" \/><figcaption id=\"caption-attachment-11676\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 1. ST website<\/span><\/figcaption><\/figure>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Here, we have the schematic, as shown in Figure 1. Let&#8217;s download this.<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">You get the PDF file when you download this, as shown in Figure 2. Open that pdf file.<\/span><\/p>\n<figure id=\"attachment_11677\" aria-describedby=\"caption-attachment-11677\" style=\"width: 663px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"wp-image-11677 \" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/09\/Figure-2-6-1024x498.png\" alt=\"Figure 2. Pdf file\" width=\"663\" height=\"323\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-2-6-1024x498.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-2-6-300x146.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-2-6-768x374.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-2-6-600x292.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-2-6-200x97.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-2-6-400x195.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-2-6-800x389.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-2-6-1200x584.png 1200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-2-6.png 1313w\" sizes=\"(max-width: 663px) 100vw, 663px\" \/><figcaption id=\"caption-attachment-11677\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 2. Pdf file<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">In the schematic, you can search for the LEDs. If you browse the document, you find LEDs, as shown in Figure 3.&nbsp;<\/span><\/p>\n<figure id=\"attachment_11678\" aria-describedby=\"caption-attachment-11678\" style=\"width: 643px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"wp-image-11678 \" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/09\/Figure-3-5-1024x651.png\" alt=\"Figure 3. LEDs in the board\" width=\"643\" height=\"409\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-3-5-1024x651.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-3-5-300x191.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-3-5-768x488.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-3-5-600x381.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-3-5-200x127.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-3-5-400x254.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-3-5-800x508.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-3-5-1200x763.png 1200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-3-5.png 1251w\" sizes=\"(max-width: 643px) 100vw, 643px\" \/><figcaption id=\"caption-attachment-11678\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 3. LEDs in the board<\/span><\/figcaption><\/figure>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Here you can see that this board has 4 LEDs. The part number of the Green LED is LD4, the part number of the Orange LED is LD3, and so on. On the board, you can identify the LEDs by these names. So, these are the part numbers that should be mentioned on the board as well.<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">For that, you have to go to the user manual, as shown in Figure 4. Let&#8217;s open the user manual.<\/span><\/p>\n<figure id=\"attachment_11679\" aria-describedby=\"caption-attachment-11679\" style=\"width: 706px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-11679 \" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/09\/Figure-4-4-1024x555.png\" alt=\"Figure 4. User manual\" width=\"706\" height=\"383\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-4-4-1024x555.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-4-4-300x163.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-4-4-768x416.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-4-4-600x325.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-4-4-1536x832.png 1536w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-4-4-200x108.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-4-4-400x217.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-4-4-800x433.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-4-4-1200x650.png 1200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-4-4.png 1733w\" sizes=\"(max-width: 706px) 100vw, 706px\" \/><figcaption id=\"caption-attachment-11679\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 4. User manual<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400;\">&nbsp;<span style=\"color: #000000;\">In the user manual, you can see that they have explained the board.&nbsp;<\/span><\/span><span style=\"font-weight: 400; color: #000000;\">&nbsp;<\/span><\/p>\n<figure id=\"attachment_11680\" aria-describedby=\"caption-attachment-11680\" style=\"width: 622px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-11680\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/09\/Figure-6-2-1024x629.png\" alt=\"Coding to Turn on an LED\" width=\"622\" height=\"382\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-6-2-1024x629.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-6-2-300x184.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-6-2-768x472.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-6-2-600x369.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-6-2-200x123.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-6-2-400x246.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-6-2-800x492.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-6-2-1200x737.png 1200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-6-2.png 1525w\" sizes=\"(max-width: 622px) 100vw, 622px\" \/><figcaption id=\"caption-attachment-11680\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 5. STM32F4DISCOVERY top layout<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Let\u2019s zoom on the board. You can see that LD4, LD5, LD6, these are the LEDs. So, they have a mention here. Just explore this figure in the user manual.<\/span><\/p>\n<figure id=\"attachment_11681\" aria-describedby=\"caption-attachment-11681\" style=\"width: 548px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-11681\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/09\/Figure-7-1024x520.png\" alt=\"Coding to Turn on an LED\" width=\"548\" height=\"278\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-7-1024x520.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-7-300x152.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-7-768x390.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-7-600x305.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-7-1536x781.png 1536w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-7-200x102.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-7-400x203.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-7-800x407.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-7-1200x610.png 1200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-7.png 1903w\" sizes=\"(max-width: 548px) 100vw, 548px\" \/><figcaption id=\"caption-attachment-11681\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 6. Zoomed out picture of the board<\/span><\/figcaption><\/figure>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Figure 3 shows how the LEDs are connected to the microcontroller pin. The Green LED is connected to the pin PD12; PD12 means Port D PIN number 12. And the LED Blue is connected to PD15, that is, Port D PIN number 15. That leads to our next discussion.<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 25px; line-height: 45px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"text-decoration: underline; color: #000080;\"><b>Ports<\/b><span style=\"font-weight: 400;\">&nbsp;<\/span><\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">STM32F407VGT6 Microcontroller has many ports, and we can identify all these ports by going through the schematic again.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">If you go to the schematic, there is a picture of the microcontroller. U4A is a part number of the microcontroller, and the microcontroller is STM32F407VGT6. And it has many pins, but on this board, all these pins are exposed.<\/span><\/p>\n<figure id=\"attachment_11683\" aria-describedby=\"caption-attachment-11683\" style=\"width: 595px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-11683\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/09\/Figure-8-1024x560.png\" alt=\"Coding to Turn on an LED\" width=\"595\" height=\"326\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-8-1024x560.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-8-300x164.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-8-768x420.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-8-600x328.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-8-1536x840.png 1536w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-8-200x109.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-8-400x219.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-8-800x437.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-8-1200x656.png 1200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-8.png 1889w\" sizes=\"(max-width: 595px) 100vw, 595px\" \/><figcaption id=\"caption-attachment-11683\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 7. Ports<\/span><\/figcaption><\/figure>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">In STM32Fx based MCUs, each port has 16 pins where you can connect external peripherals such as LED, Display, button, Bluetooth transceiver, external memory(e.g.EEPROM),&nbsp; Joystick, keypad, etc.<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">If you want to do those external connections, you can take help from these ports, which are exposed on the board. So, if you look into this picture, all these pins can be segregated into different ports like Port-A, Port-E, Port-D, and each port is a collection of 16 pins.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400;\"><span style=\"color: #000000;\">For example, all these PA0 to PA15 pins belong to Port A. The first pin is called PA0(that is Port A PIN number 0), and the last pin here is PA15. And 23, 24, 25, and so on are the PIN numbers of the microcontroller. That means, the microcontroller&#8217;s 23 pin is PA0, which is the 0th pin of Port A. It&#8217;s like that.<\/span>&nbsp;<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">This microcontroller has many ports like Port-F,&nbsp; Port-G, Port-H, etc., but only these ports are exposed on the board.&nbsp;<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Now let&#8217;s consider LED 4, which is LD4. This LED is connected to PD12 exactly like this, as shown in Figure 8. Here is a microcontroller and Port-D, and at the 12th pin, this LED is connected.<\/span><\/p>\n<figure id=\"attachment_11684\" aria-describedby=\"caption-attachment-11684\" style=\"width: 631px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-11684\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/09\/Figure-9-1024x535.png\" alt=\"Coding to Turn on an LED\" width=\"631\" height=\"330\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-9-1024x535.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-9-300x157.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-9-768x402.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-9-600x314.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-9-1536x803.png 1536w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-9-200x105.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-9-400x209.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-9-800x418.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-9-1200x627.png 1200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-9.png 1861w\" sizes=\"(max-width: 631px) 100vw, 631px\" \/><figcaption id=\"caption-attachment-11684\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 8. LED4 connection<\/span><\/figcaption><\/figure>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">How do you access the 12th pin of GPIO PORT-D?&nbsp;<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Port-D is also called GPIO Port D. GPIO stands for General-Purpose Input\/Output. PD0 to PD15 are called General-purpose I\/Os, because it can be used for any purpose. Like you can use that to connect external peripherals, or you can use that pins to do some other protocol communication like Ethernet communication, UART communication, I2C communication, etc. That&#8217;s why these pins are called General-purpose I\/Os.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Now you have to think about controlling this PD12 pin. If you control the PD12 pin, you can control the LED. So now the question is, how do you control this pin from the software.<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Now your goal is to control the I\/O pin PD12&#8217;s state, either HIGH or LOW through the software to make LED turn ON or turn OFF, and we are going to learn that.&nbsp; You have to understand how these pins are controlled from the microcontroller, and we understand that in the <span style=\"color: #ff6600;\"><a style=\"color: #ff6600; text-decoration: underline;\" href=\"http:\/\/fastbitlab.com\/microcontroller-embedded-c-programming-lecture-105-controlling-io-pin-using-software\/\" target=\"_blank\" rel=\"noopener\">following article<\/a><\/span>.<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 20px; border-width: 0px; line-height: 30px;\"><span style=\"color: #000080;\"><b>FastBit Embedded Brain Academy Courses<\/b><\/span><\/p>\n<p class=\"\" style=\"font-size: 18px; border-width: 0px;\"><span style=\"color: #000000;\">C<span style=\"font-weight: 400;\"><span style=\"color: #000000;\">lick here:<\/span>&nbsp;<\/span><\/span><span style=\"color: #0000ff;\"><a style=\"color: #0000ff; text-decoration: underline;\" href=\"http:\/\/fastbitlab.com\/course1\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">https:\/\/fastbitlab.com\/course1<\/span><\/a><\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Coding to Turn on an LED &nbsp; &nbsp; &nbsp; Exercise: Write a program to turn on the LED of your target board. For this exercise, we need the knowledge of&nbsp; pointers&nbsp; bitwise operators&nbsp; Hardware connections &nbsp; Hardware connections Let&#8217;s understand how external hardware(LED) is connected to the microcontroller.&nbsp; For this, we have to refer [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":11678,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ocean_post_layout":"","ocean_both_sidebars_style":"","ocean_both_sidebars_content_width":0,"ocean_both_sidebars_sidebars_width":0,"ocean_sidebar":"0","ocean_second_sidebar":"0","ocean_disable_margins":"enable","ocean_add_body_class":"","ocean_shortcode_before_top_bar":"","ocean_shortcode_after_top_bar":"","ocean_shortcode_before_header":"","ocean_shortcode_after_header":"","ocean_has_shortcode":"","ocean_shortcode_after_title":"","ocean_shortcode_before_footer_widgets":"","ocean_shortcode_after_footer_widgets":"","ocean_shortcode_before_footer_bottom":"","ocean_shortcode_after_footer_bottom":"","ocean_display_top_bar":"default","ocean_display_header":"default","ocean_header_style":"","ocean_center_header_left_menu":"0","ocean_custom_header_template":"0","ocean_custom_logo":0,"ocean_custom_retina_logo":0,"ocean_custom_logo_max_width":0,"ocean_custom_logo_tablet_max_width":0,"ocean_custom_logo_mobile_max_width":0,"ocean_custom_logo_max_height":0,"ocean_custom_logo_tablet_max_height":0,"ocean_custom_logo_mobile_max_height":0,"ocean_header_custom_menu":"0","ocean_menu_typo_font_family":"0","ocean_menu_typo_font_subset":"","ocean_menu_typo_font_size":0,"ocean_menu_typo_font_size_tablet":0,"ocean_menu_typo_font_size_mobile":0,"ocean_menu_typo_font_size_unit":"px","ocean_menu_typo_font_weight":"","ocean_menu_typo_font_weight_tablet":"","ocean_menu_typo_font_weight_mobile":"","ocean_menu_typo_transform":"","ocean_menu_typo_transform_tablet":"","ocean_menu_typo_transform_mobile":"","ocean_menu_typo_line_height":0,"ocean_menu_typo_line_height_tablet":0,"ocean_menu_typo_line_height_mobile":0,"ocean_menu_typo_line_height_unit":"","ocean_menu_typo_spacing":0,"ocean_menu_typo_spacing_tablet":0,"ocean_menu_typo_spacing_mobile":0,"ocean_menu_typo_spacing_unit":"","ocean_menu_link_color":"","ocean_menu_link_color_hover":"","ocean_menu_link_color_active":"","ocean_menu_link_background":"","ocean_menu_link_hover_background":"","ocean_menu_link_active_background":"","ocean_menu_social_links_bg":"","ocean_menu_social_hover_links_bg":"","ocean_menu_social_links_color":"","ocean_menu_social_hover_links_color":"","ocean_disable_title":"default","ocean_disable_heading":"default","ocean_post_title":"","ocean_post_subheading":"","ocean_post_title_style":"","ocean_post_title_background_color":"","ocean_post_title_background":0,"ocean_post_title_bg_image_position":"","ocean_post_title_bg_image_attachment":"","ocean_post_title_bg_image_repeat":"","ocean_post_title_bg_image_size":"","ocean_post_title_height":0,"ocean_post_title_bg_overlay":0.5,"ocean_post_title_bg_overlay_color":"","ocean_disable_breadcrumbs":"default","ocean_breadcrumbs_color":"","ocean_breadcrumbs_separator_color":"","ocean_breadcrumbs_links_color":"","ocean_breadcrumbs_links_hover_color":"","ocean_display_footer_widgets":"default","ocean_display_footer_bottom":"default","ocean_custom_footer_template":"0","ocean_post_oembed":"","ocean_post_self_hosted_media":"","ocean_post_video_embed":"","ocean_link_format":"","ocean_link_format_target":"self","ocean_quote_format":"","ocean_quote_format_link":"post","ocean_gallery_link_images":"off","ocean_gallery_id":[],"footnotes":""},"categories":[8],"tags":[16],"class_list":["post-11673","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-microcontroller-embedded-c-programming","entry","has-media"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Coding to turn on the LED of your target board |Step-by-Step Guide<\/title>\n<meta name=\"description\" content=\"Exercise: Write a program to turn on the LED of your target board. Learn how to write code to turn on an LED using pointers, bitwise operator\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/fastbitlab.com\/blog\/coding-to-turn-on-an-led\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Coding to turn on the LED of your target board |Step-by-Step Guide\" \/>\n<meta property=\"og:description\" content=\"Exercise: Write a program to turn on the LED of your target board. Learn how to write code to turn on an LED using pointers, bitwise operator\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fastbitlab.com\/blog\/coding-to-turn-on-an-led\/\" \/>\n<meta property=\"og:site_name\" content=\"FastBit EBA\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/fastbiteba\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-09-12T04:22:55+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-08-25T10:17:05+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-3-5.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1251\" \/>\n\t<meta property=\"og:image:height\" content=\"795\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"FastBitLab\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@fastbiteba\" \/>\n<meta name=\"twitter:site\" content=\"@fastbiteba\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"FastBitLab\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/coding-to-turn-on-an-led\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/coding-to-turn-on-an-led\\\/\"},\"author\":{\"name\":\"FastBitLab\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/person\\\/e32b38e733a0d76ffa7e6bc998652e5d\"},\"headline\":\"Microcontroller Embedded C Programming Lecture 104| Coding to Turn on an LED\",\"datePublished\":\"2022-09-12T04:22:55+00:00\",\"dateModified\":\"2023-08-25T10:17:05+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/coding-to-turn-on-an-led\\\/\"},\"wordCount\":896,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/coding-to-turn-on-an-led\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/09\\\/Figure-3-5.png\",\"keywords\":[\"Microcontroller Embedded C programming Lectures\"],\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/coding-to-turn-on-an-led\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/coding-to-turn-on-an-led\\\/\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/coding-to-turn-on-an-led\\\/\",\"name\":\"Coding to turn on the LED of your target board |Step-by-Step Guide\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/coding-to-turn-on-an-led\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/coding-to-turn-on-an-led\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/09\\\/Figure-3-5.png\",\"datePublished\":\"2022-09-12T04:22:55+00:00\",\"dateModified\":\"2023-08-25T10:17:05+00:00\",\"description\":\"Exercise: Write a program to turn on the LED of your target board. Learn how to write code to turn on an LED using pointers, bitwise operator\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/coding-to-turn-on-an-led\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/coding-to-turn-on-an-led\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/coding-to-turn-on-an-led\\\/#primaryimage\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/09\\\/Figure-3-5.png\",\"contentUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/09\\\/Figure-3-5.png\",\"width\":1251,\"height\":795,\"caption\":\"Figure 3. LEDs in the board\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/coding-to-turn-on-an-led\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Microcontroller Embedded C Programming Lecture 104| Coding to Turn on an LED\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\",\"name\":\"FastBit EBA\",\"description\":\"Your Online Academy of Embedded Systems\",\"publisher\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\",\"name\":\"FastBit EBA\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/logo-EzNrEnyr.png\",\"contentUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/logo-EzNrEnyr.png\",\"width\":640,\"height\":640,\"caption\":\"FastBit EBA\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/fastbiteba\\\/\",\"https:\\\/\\\/x.com\\\/fastbiteba\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/fastbit-embedded-brain-academy-b3167b124\\\/\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCa1REBV9hyrzGp2mjJCagBg\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/person\\\/e32b38e733a0d76ffa7e6bc998652e5d\",\"name\":\"FastBitLab\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g\",\"caption\":\"FastBitLab\"},\"description\":\"The FastBit Embedded Brain Academy uses the power of internet to bring the online courses related to the field of embedded system programming, Real time operating system, Embedded Linux systems, etc at your finger tip with very low cost. Backed with strong experience of industry, we have produced lots of courses with the customer enrolment over 3000+ across 100+ countries.\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Coding to turn on the LED of your target board |Step-by-Step Guide","description":"Exercise: Write a program to turn on the LED of your target board. Learn how to write code to turn on an LED using pointers, bitwise operator","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/fastbitlab.com\/blog\/coding-to-turn-on-an-led\/","og_locale":"en_US","og_type":"article","og_title":"Coding to turn on the LED of your target board |Step-by-Step Guide","og_description":"Exercise: Write a program to turn on the LED of your target board. Learn how to write code to turn on an LED using pointers, bitwise operator","og_url":"https:\/\/fastbitlab.com\/blog\/coding-to-turn-on-an-led\/","og_site_name":"FastBit EBA","article_publisher":"https:\/\/www.facebook.com\/fastbiteba\/","article_published_time":"2022-09-12T04:22:55+00:00","article_modified_time":"2023-08-25T10:17:05+00:00","og_image":[{"width":1251,"height":795,"url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-3-5.png","type":"image\/png"}],"author":"FastBitLab","twitter_card":"summary_large_image","twitter_creator":"@fastbiteba","twitter_site":"@fastbiteba","twitter_misc":{"Written by":"FastBitLab","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fastbitlab.com\/blog\/coding-to-turn-on-an-led\/#article","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/coding-to-turn-on-an-led\/"},"author":{"name":"FastBitLab","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/person\/e32b38e733a0d76ffa7e6bc998652e5d"},"headline":"Microcontroller Embedded C Programming Lecture 104| Coding to Turn on an LED","datePublished":"2022-09-12T04:22:55+00:00","dateModified":"2023-08-25T10:17:05+00:00","mainEntityOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/coding-to-turn-on-an-led\/"},"wordCount":896,"commentCount":0,"publisher":{"@id":"https:\/\/fastbitlab.com\/blog\/#organization"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/coding-to-turn-on-an-led\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-3-5.png","keywords":["Microcontroller Embedded C programming Lectures"],"articleSection":["Blog"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fastbitlab.com\/blog\/coding-to-turn-on-an-led\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/fastbitlab.com\/blog\/coding-to-turn-on-an-led\/","url":"https:\/\/fastbitlab.com\/blog\/coding-to-turn-on-an-led\/","name":"Coding to turn on the LED of your target board |Step-by-Step Guide","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/coding-to-turn-on-an-led\/#primaryimage"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/coding-to-turn-on-an-led\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-3-5.png","datePublished":"2022-09-12T04:22:55+00:00","dateModified":"2023-08-25T10:17:05+00:00","description":"Exercise: Write a program to turn on the LED of your target board. Learn how to write code to turn on an LED using pointers, bitwise operator","breadcrumb":{"@id":"https:\/\/fastbitlab.com\/blog\/coding-to-turn-on-an-led\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fastbitlab.com\/blog\/coding-to-turn-on-an-led\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fastbitlab.com\/blog\/coding-to-turn-on-an-led\/#primaryimage","url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-3-5.png","contentUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-3-5.png","width":1251,"height":795,"caption":"Figure 3. LEDs in the board"},{"@type":"BreadcrumbList","@id":"https:\/\/fastbitlab.com\/blog\/coding-to-turn-on-an-led\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/fastbitlab.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Microcontroller Embedded C Programming Lecture 104| Coding to Turn on an LED"}]},{"@type":"WebSite","@id":"https:\/\/fastbitlab.com\/blog\/#website","url":"https:\/\/fastbitlab.com\/blog\/","name":"FastBit EBA","description":"Your Online Academy of Embedded Systems","publisher":{"@id":"https:\/\/fastbitlab.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/fastbitlab.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/fastbitlab.com\/blog\/#organization","name":"FastBit EBA","url":"https:\/\/fastbitlab.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2026\/04\/logo-EzNrEnyr.png","contentUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2026\/04\/logo-EzNrEnyr.png","width":640,"height":640,"caption":"FastBit EBA"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/fastbiteba\/","https:\/\/x.com\/fastbiteba","https:\/\/www.linkedin.com\/in\/fastbit-embedded-brain-academy-b3167b124\/","https:\/\/www.youtube.com\/channel\/UCa1REBV9hyrzGp2mjJCagBg"]},{"@type":"Person","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/person\/e32b38e733a0d76ffa7e6bc998652e5d","name":"FastBitLab","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g","caption":"FastBitLab"},"description":"The FastBit Embedded Brain Academy uses the power of internet to bring the online courses related to the field of embedded system programming, Real time operating system, Embedded Linux systems, etc at your finger tip with very low cost. Backed with strong experience of industry, we have produced lots of courses with the customer enrolment over 3000+ across 100+ countries."}]}},"_links":{"self":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/11673","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/comments?post=11673"}],"version-history":[{"count":5,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/11673\/revisions"}],"predecessor-version":[{"id":14420,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/11673\/revisions\/14420"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media\/11678"}],"wp:attachment":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media?parent=11673"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/categories?post=11673"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/tags?post=11673"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}