{"id":690,"date":"2021-01-10T15:28:00","date_gmt":"2021-01-10T07:28:00","guid":{"rendered":"http:\/\/bversion.com\/WordPress\/?p=690"},"modified":"2021-03-09T21:18:34","modified_gmt":"2021-03-09T13:18:34","slug":"anode-vs-cathode","status":"publish","type":"post","link":"https:\/\/bversion.com\/WordPress\/2021\/01\/10\/anode-vs-cathode\/","title":{"rendered":"Anode vs Cathode"},"content":{"rendered":"\n<figure class=\"wp-block-video\"><video height=\"1080\" style=\"aspect-ratio: 1920 \/ 1080;\" width=\"1920\" controls src=\"http:\/\/bversion.com\/WordPress\/wp-content\/uploads\/2021\/03\/Anode-vs-Cathode.mp4\"><\/video><\/figure>\n\n\n\n<p>When you deal with diode or transistor components such as LED, 7 Segment display, RGB LED, etc., you need to understand whether the component is common anode or common cathode, it will give you completely different result. <\/p>\n\n\n<style>.wp-block-kadence-advancedheading.kt-adv-heading_1b1345-44, .wp-block-kadence-advancedheading.kt-adv-heading_1b1345-44[data-kb-block=\"kb-adv-heading_1b1345-44\"]{font-style:normal;}.wp-block-kadence-advancedheading.kt-adv-heading_1b1345-44 mark.kt-highlight, .wp-block-kadence-advancedheading.kt-adv-heading_1b1345-44[data-kb-block=\"kb-adv-heading_1b1345-44\"] mark.kt-highlight{font-style:normal;color:#f76a0c;-webkit-box-decoration-break:clone;box-decoration-break:clone;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;}.wp-block-kadence-advancedheading.kt-adv-heading_1b1345-44 img.kb-inline-image, .wp-block-kadence-advancedheading.kt-adv-heading_1b1345-44[data-kb-block=\"kb-adv-heading_1b1345-44\"] img.kb-inline-image{width:150px;vertical-align:baseline;}<\/style>\n<h2 class=\"kt-adv-heading_1b1345-44 wp-block-kadence-advancedheading\" data-kb-block=\"kb-adv-heading_1b1345-44\">7 Segment Display<\/h2>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-vertically-aligned-top is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-image size-large\"><a href=\"http:\/\/bversion.com\/WordPress\/wp-content\/uploads\/2021\/02\/7-Segment.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"581\" height=\"1024\" src=\"http:\/\/bversion.com\/WordPress\/wp-content\/uploads\/2021\/02\/7-Segment-581x1024.jpg\" alt=\"\" class=\"wp-image-496\" srcset=\"https:\/\/bversion.com\/WordPress\/wp-content\/uploads\/2021\/02\/7-Segment-581x1024.jpg 581w, https:\/\/bversion.com\/WordPress\/wp-content\/uploads\/2021\/02\/7-Segment-170x300.jpg 170w, https:\/\/bversion.com\/WordPress\/wp-content\/uploads\/2021\/02\/7-Segment-768x1354.jpg 768w, https:\/\/bversion.com\/WordPress\/wp-content\/uploads\/2021\/02\/7-Segment-871x1536.jpg 871w, https:\/\/bversion.com\/WordPress\/wp-content\/uploads\/2021\/02\/7-Segment.jpg 1064w\" sizes=\"auto, (max-width: 581px) 100vw, 581px\" \/><\/a><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p>Let&#8217;s us the 7 Segment display as example. <\/p>\n\n\n\n<p>All a &#8211; g &amp; dp are connected to a &#8216;common&#8217;. When the common is common anode, we need to connect this to a high voltage, sometime 5V, so that current will be generated when a &#8211; g &amp; dp is <strong>LOW<\/strong>. On the other hand, if the common is common ground, we need to connect this to a low voltage, most of the time is ground, so that current will be generated when a &#8211; g &amp; dp is <strong>HIGH<\/strong>.<\/p>\n\n\n\n<p>Common anode &#8211; the segment will be lit if the signal pins a &#8211; f &amp; dp is LOW<\/p>\n\n\n\n<p>Common cathode &#8211; the segment will be lit if the signal pins a -f &amp; dp is HIGH.<\/p>\n<\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-image size-large\"><a href=\"http:\/\/bversion.com\/WordPress\/wp-content\/uploads\/2021\/03\/VideoCapture_20210309-132629.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"http:\/\/bversion.com\/WordPress\/wp-content\/uploads\/2021\/03\/VideoCapture_20210309-132629-1024x576.jpg\" alt=\"\" class=\"wp-image-698\" srcset=\"https:\/\/bversion.com\/WordPress\/wp-content\/uploads\/2021\/03\/VideoCapture_20210309-132629-1024x576.jpg 1024w, https:\/\/bversion.com\/WordPress\/wp-content\/uploads\/2021\/03\/VideoCapture_20210309-132629-300x169.jpg 300w, https:\/\/bversion.com\/WordPress\/wp-content\/uploads\/2021\/03\/VideoCapture_20210309-132629-768x432.jpg 768w, https:\/\/bversion.com\/WordPress\/wp-content\/uploads\/2021\/03\/VideoCapture_20210309-132629-1536x864.jpg 1536w, https:\/\/bversion.com\/WordPress\/wp-content\/uploads\/2021\/03\/VideoCapture_20210309-132629.jpg 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-image size-large\"><a href=\"http:\/\/bversion.com\/WordPress\/wp-content\/uploads\/2021\/03\/VideoCapture_20210309-132638.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"http:\/\/bversion.com\/WordPress\/wp-content\/uploads\/2021\/03\/VideoCapture_20210309-132638-1024x576.jpg\" alt=\"\" class=\"wp-image-700\" srcset=\"https:\/\/bversion.com\/WordPress\/wp-content\/uploads\/2021\/03\/VideoCapture_20210309-132638-1024x576.jpg 1024w, https:\/\/bversion.com\/WordPress\/wp-content\/uploads\/2021\/03\/VideoCapture_20210309-132638-300x169.jpg 300w, https:\/\/bversion.com\/WordPress\/wp-content\/uploads\/2021\/03\/VideoCapture_20210309-132638-768x432.jpg 768w, https:\/\/bversion.com\/WordPress\/wp-content\/uploads\/2021\/03\/VideoCapture_20210309-132638-1536x864.jpg 1536w, https:\/\/bversion.com\/WordPress\/wp-content\/uploads\/2021\/03\/VideoCapture_20210309-132638.jpg 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/div>\n<\/div>\n\n\n\n<p>As you can see from the above photos, left display is common cathode and right one is common anode. When we display a number 4 to the common cathode display, it will give the opposite result from the common anode.  If you display a number 4 in the common anode device, it will give the same opposite result in common cathode device.<\/p>\n\n\n<style>.wp-block-kadence-advancedheading.kt-adv-heading_069bfd-1e, .wp-block-kadence-advancedheading.kt-adv-heading_069bfd-1e[data-kb-block=\"kb-adv-heading_069bfd-1e\"]{font-style:normal;}.wp-block-kadence-advancedheading.kt-adv-heading_069bfd-1e mark.kt-highlight, .wp-block-kadence-advancedheading.kt-adv-heading_069bfd-1e[data-kb-block=\"kb-adv-heading_069bfd-1e\"] mark.kt-highlight{font-style:normal;color:#f76a0c;-webkit-box-decoration-break:clone;box-decoration-break:clone;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;}.wp-block-kadence-advancedheading.kt-adv-heading_069bfd-1e img.kb-inline-image, .wp-block-kadence-advancedheading.kt-adv-heading_069bfd-1e[data-kb-block=\"kb-adv-heading_069bfd-1e\"] img.kb-inline-image{width:150px;vertical-align:baseline;}<\/style>\n<h2 class=\"kt-adv-heading_069bfd-1e wp-block-kadence-advancedheading\" data-kb-block=\"kb-adv-heading_069bfd-1e\">Switching between 1 &amp; 0<\/h2>\n\n\n\n<p>So, when you develop the program, you need to understand what device is going to use. Otherwise, you need to do some switching between 1 &amp; 0, just like the program below.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"42\" data-enlighter-linenumbers=\"false\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">int start_pin = 2;\n\nvoid setup() {\n  \/\/ put your setup code here, to run once:\n  int p;\n  for (p=start_pin; p&lt;start_pin+7; p++){\n    pinMode(p, OUTPUT);\n  }\n}\n\nvoid loop() {\n  \/\/ put your main code here, to run repeatedly:\n  int i = 0;\n  int j = 0;\n  int number = 0;\n  int d = 0;\n  int segment = 0;\n  const int number_array[][10]={{1,1,1,1,1,1,0},\n                                {0,1,1,0,0,0,0},\n                                {1,1,0,1,1,0,1},\n                                {1,1,1,1,0,0,1},\n                                {0,1,1,0,0,1,1},\n                                {1,0,1,1,0,1,1},\n                                {1,0,1,1,1,1,1},\n                                {1,1,1,0,0,0,0},\n                                {1,1,1,1,1,1,1},\n                                {1,1,1,0,0,1,1}\n                                };\n\n  for (number=0;number&lt;10;number++){\n    for (d=0;d&lt;100;d++){\n      for (segment=0;segment&lt;8;segment++){\n        digitalWrite(start_pin+segment, number_array[number][segment]);\n      }\n    delay(10);  \n    }      \n  }\n\n  for (number=0;number&lt;10;number++){\n    for (d=0;d&lt;100;d++){\n      for (segment=0;segment&lt;8;segment++){\n        digitalWrite(start_pin+segment, not number_array[number][segment]);\n      }\n    delay(10);  \n    }      \n  }\n}<\/pre>\n\n\n\n<p>This program is developed with common cathode assumed, the number_array with 1 is on, 0 is off, i.e. 4 is 0110011. When apply the same pattern to the common anode device, it will look like &#8216;1001100&#8217;, the monster you see in those picture. <\/p>\n\n\n\n<p>So, we add a &#8216;not&#8217; to the line we highlighted in the code, it will give the opposite value to the pin, i.e. 1 -&gt; 0,  0 -&gt; 1. Thus, the data output of 4 will be changed from &#8216;0110011&#8217; to &#8216;1001100&#8217;, it will be 4 in the common anode but a monster in common cathode.<\/p>\n\n\n<style>.wp-block-kadence-advancedheading.kt-adv-heading_23291d-95, .wp-block-kadence-advancedheading.kt-adv-heading_23291d-95[data-kb-block=\"kb-adv-heading_23291d-95\"]{font-style:normal;}.wp-block-kadence-advancedheading.kt-adv-heading_23291d-95 mark.kt-highlight, .wp-block-kadence-advancedheading.kt-adv-heading_23291d-95[data-kb-block=\"kb-adv-heading_23291d-95\"] mark.kt-highlight{font-style:normal;color:#f76a0c;-webkit-box-decoration-break:clone;box-decoration-break:clone;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;}.wp-block-kadence-advancedheading.kt-adv-heading_23291d-95 img.kb-inline-image, .wp-block-kadence-advancedheading.kt-adv-heading_23291d-95[data-kb-block=\"kb-adv-heading_23291d-95\"] img.kb-inline-image{width:150px;vertical-align:baseline;}<\/style>\n<h2 class=\"kt-adv-heading_23291d-95 wp-block-kadence-advancedheading\" data-kb-block=\"kb-adv-heading_23291d-95\">RGB LED<\/h2>\n\n\n\n<p>7 segment is quite easy to hand. But, take a look of RGB LED. I would prefer using common cathode RGB LED, because it is easy for me just follow the color code. But for common anode one, you need to do something like 255 &#8211; the color code as shown below, have a try!<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"false\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">  analogWrite (red, 255 - 232); # Color code 232, 97, 0 (E86100)\n  analogWrite (green, 255 - 97);\n  analogWrite (blue, 255 - 0);\n  delay(1000);  \n  \n  analogWrite (red, 255 - 199); # Color code 199, 128, 35 (C78023)\n  analogWrite (green, 255 - 128);\n  analogWrite (blue, 255 - 35);\n  delay(1000);  <\/pre>\n","protected":false},"excerpt":{"rendered":"<p>When you deal with diode or transistor components such as LED, 7 Segment display, RGB LED, etc., you need to understand whether the component is common anode or common cathode, it will give you completely different result. 7 Segment Display Let&#8217;s us the 7 Segment display as example. All a &#8211; g &amp; dp are &hellip; <a href=\"https:\/\/bversion.com\/WordPress\/2021\/01\/10\/anode-vs-cathode\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Anode vs Cathode<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":698,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"cybocfi_hide_featured_image":"yes","footnotes":""},"categories":[5],"tags":[],"class_list":["post-690","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-world-of-arduino"],"_links":{"self":[{"href":"https:\/\/bversion.com\/WordPress\/wp-json\/wp\/v2\/posts\/690","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bversion.com\/WordPress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bversion.com\/WordPress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bversion.com\/WordPress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bversion.com\/WordPress\/wp-json\/wp\/v2\/comments?post=690"}],"version-history":[{"count":14,"href":"https:\/\/bversion.com\/WordPress\/wp-json\/wp\/v2\/posts\/690\/revisions"}],"predecessor-version":[{"id":714,"href":"https:\/\/bversion.com\/WordPress\/wp-json\/wp\/v2\/posts\/690\/revisions\/714"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/bversion.com\/WordPress\/wp-json\/wp\/v2\/media\/698"}],"wp:attachment":[{"href":"https:\/\/bversion.com\/WordPress\/wp-json\/wp\/v2\/media?parent=690"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bversion.com\/WordPress\/wp-json\/wp\/v2\/categories?post=690"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bversion.com\/WordPress\/wp-json\/wp\/v2\/tags?post=690"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}