{"id":311,"date":"2015-10-23T16:04:40","date_gmt":"2015-10-23T16:04:40","guid":{"rendered":"https:\/\/einhugur.com\/blog\/?page_id=311"},"modified":"2021-04-15T13:20:09","modified_gmt":"2021-04-15T13:20:09","slug":"putting-the-gpio-pin-behind-transistor-to-get-more-current","status":"publish","type":"page","link":"https:\/\/einhugur.net\/blog\/index.php\/xojo-gpio\/putting-the-gpio-pin-behind-transistor-to-get-more-current\/","title":{"rendered":"Putting the GPIO pin behind transistor to get more current"},"content":{"rendered":"<h2>In this example we are going to let the GPIO pin control a transistor so that we can draw more power when controlling a LED than what the GPIO pin can supply.<\/h2>\n<p>We will be using a simple LED in this example where we aim to draw 16 mA power (I could easily go higher using this method if I had bigger LED that can draw more power\u00a0since the current will mostly come from the 5V and not from the GPIO pin it self), load on the GPIO pin will only be around 0,00018 A.<\/p>\n<p>At far bottom of this article we will also deal with the initial undetermined state of the GPIO pin.<\/p>\n<p>A transistor is basically a switch that is triggered by tiny electric signal. <a href=\"https:\/\/einhugur.com\/blog\/index.php\/understanding-transistor-specification-sheets\/\">(See here how to understand transistor specification sheets)<\/a><\/p>\n<p>Transistor is suitable to use when switching within the same circuit. While if the power your switching is in completely different circuit then you would want to use a\u00a0optocoupler which is another kind of electric switch where only light\u00a0signal is sent between the two circuits keeping them isolated. (<a href=\"https:\/\/einhugur.com\/blog\/index.php\/xojo-gpio\/optocouplers\/\">See our guide about Optocouplers<\/a>)<\/p>\n<p>There are NPN and PNP transistors. The NPN ones switch on the low side (-) while PNP transistors switch on the high side (+). This is important difference and for example this difference would mean that the NPN transistor that we will be using in this example would not have been suitable for the <a href=\"https:\/\/einhugur.com\/blog\/index.php\/xojo-gpio\/working-with-leds-and-wiring-4-pin-rgb-led-to-raspberry-pi\/\">RGB LED example <\/a>since there we would need to switch on the high side (+) as the RGB LED had 3 anodes (+) and only one cathode (-). In the RGB LED example the LED was not shining very bright at all since we could not provide a lot of power from the GPIO pin, a transistor solves such issues.<\/p>\n<p><strong>Disclaimer:<\/strong><br \/>\nWe do not take any responsibility for possible errors in the guide or errors that you might do wiring it up. Incorrect wiring can result in damaged sensor or damaged Raspberry PI.<\/p>\n<h5><strong>Pieces we use are:<\/strong><\/h5>\n<ul>\n<li>Raspberry PI 2<\/li>\n<li>Cobbler and Cobbler cable<\/li>\n<li>Bread board<\/li>\n<li>Green LED <span style=\"color: #808080;\">(can be any LED you want)<\/span><\/li>\n<li>2N3904 Transistor<span style=\"color: #999999;\"> (This one is common generic use NPN transistor, which you can easily substitute with many other such as BC548 and others). Their really cheap, I paid $1.22 for 100 pieces in store\u00a0called\u00a0<a class=\"store-lnk\" title=\"Electronic Gadget World\" href=\"http:\/\/www.aliexpress.com\/store\/1512066\" target=\"_blank\" rel=\"noopener\">Electronic Gadget World<\/a>\u00a0on Ali Express. This included free shipping to Iceland. Thats 1,2 cents per transistor.<\/span><\/li>\n<li>Some resistors (types depend on specs of your RGB led and your transistor)<\/li>\n<li><a href=\"https:\/\/github.com\/xojo\/GPIO\">Wiring PI Xojo module from\u00a0Paul Lefebvre<\/a><\/li>\n<\/ul>\n<p><strong>If you don&#8217;t know resistor color codings to find correct resistors then you can click the link bellow<\/strong><\/p>\n<ul>\n<li><a href=\"https:\/\/einhugur.com\/blog\/index.php\/basic-electronics\/resistor-color-codings\/\">Resistor color codings<\/a><\/li>\n<\/ul>\n<h5><strong>Drawing up the circuit:<\/strong><\/h5>\n<p>First we just draw up the circuit without knowing the values of the resistors.<\/p>\n<p><a href=\"https:\/\/i1.wp.com\/einhugur.com\/blog\/wp-content\/uploads\/2015\/10\/TransistorsWithoutValues.png?ssl=1\"><img data-attachment-id=\"317\" data-permalink=\"https:\/\/einhugur.net\/blog\/index.php\/xojo-gpio\/putting-the-gpio-pin-behind-transistor-to-get-more-current\/transistorswithoutvalues\/\" data-orig-file=\"https:\/\/i0.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/10\/TransistorsWithoutValues.png?fit=317%2C385&amp;ssl=1\" data-orig-size=\"317,385\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"TransistorsWithoutValues\" data-image-description=\"\" data-medium-file=\"https:\/\/i0.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/10\/TransistorsWithoutValues.png?fit=247%2C300&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/10\/TransistorsWithoutValues.png?fit=317%2C385&amp;ssl=1\" loading=\"lazy\" class=\"alignnone size-full wp-image-317\" src=\"https:\/\/i1.wp.com\/einhugur.com\/blog\/wp-content\/uploads\/2015\/10\/TransistorsWithoutValues.png?resize=317%2C385&#038;ssl=1\" alt=\"TransistorsWithoutValues\" width=\"317\" height=\"385\" srcset=\"https:\/\/i0.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/10\/TransistorsWithoutValues.png?w=317&amp;ssl=1 317w, https:\/\/i0.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/10\/TransistorsWithoutValues.png?resize=247%2C300&amp;ssl=1 247w\" sizes=\"(max-width: 317px) 100vw, 317px\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<p><strong>Here is what we know:<\/strong><\/p>\n<ul>\n<li>GPIO pin is 3,3 V<\/li>\n<li>The power we will be using from the Raspberry Power pins is 5 V<\/li>\n<li>The led I had was rated 1,9 &#8211; 2,5 V and 5 mA &#8211; 17,5 mA, (I will be pushing it to about 16 mA at 2,2 V)<\/li>\n<li>The transistor I had was 2N3904 which is NPN transistor. (NPN transistors usually need around 0,7 V for its base)<\/li>\n<\/ul>\n<p><strong>Now we calculate the rest:<\/strong><\/p>\n<ul>\n<li>R1 would be calculated as Ohms law, <em>R = V \/ I<br \/>\n<\/em> (5V &#8211; 2,2V) \/ 0,016 A = <span style=\"text-decoration: underline;\">175\u00a0<em>\u03a9\u00a0<\/em>\u00a0<\/span> (We will use 180\u00a0\u03a9<em>)<\/em><br \/>\n<span style=\"color: #808080;\">5 &#8211; 2,2 is because the LED will use 2,2 so we have to let the resistor take the rest of the 5 V which means resistor will be at 2,8 V.<\/span><\/li>\n<li>For R2 then the following applies:\n<ol>\n<li>We know the Base of the transistor wants around 0,7 V since that is \u00a0what NPN transistors usually want. So the voltage over R2 has to be 3,3V &#8211; 0,7V = <span style=\"text-decoration: underline;\">2,6V<\/span>.<\/li>\n<li>For the current then we need to apply the following formula: I(B) = I(C) \/\u00a0\u03b2. \u00a0<span style=\"color: #999999;\">(The\u00a0\u03b2 will usually be marked as hfc in the transistors specs)\u00a0<span style=\"color: #000000;\">You google the spec for your transistor and find the Beta Value, it will have some range depending on current, it will be marked as On characteristics in the spec. Mine has the \u03b2 spec of 100 to 300 at 10 mA and 60 to 300 at 50 mA. Since we are using 16 mA then we will choose\u00a0\u03b2 of 90.<br \/>\nWhich means I(B) will be: 0,016 \/ 90 =<span style=\"text-decoration: underline;\"> 0,00018 A<\/span>\u00a0<span style=\"color: #999999;\">(This is how little we will be taking from the GPIO pin)\u00a0<\/span><\/span><\/span><\/li>\n<\/ol>\n<\/li>\n<\/ul>\n<p><span style=\"color: #999999;\"><span style=\"color: #000000;\"><span style=\"color: #999999;\"><span style=\"color: #000000;\">Now that we have the voltage and current then R2 = 2,6 V \/ 0,00018 A = <span style=\"text-decoration: underline;\"><strong>14,4 k<em>\u03a9\u00a0<\/em><\/strong><\/span><span style=\"color: #000000;\"><em> (We will use 15 k\u03a9 resistor for R2)<\/em><\/span><\/span><\/span><\/span><\/span><\/p>\n<p><strong>We we update our circuit wit\u00a0the calculated values of R1 and R2:<\/strong><\/p>\n<p><a href=\"https:\/\/i2.wp.com\/einhugur.com\/blog\/wp-content\/uploads\/2015\/10\/Transistor-Experiment.png?ssl=1\"><img data-attachment-id=\"319\" data-permalink=\"https:\/\/einhugur.net\/blog\/index.php\/xojo-gpio\/putting-the-gpio-pin-behind-transistor-to-get-more-current\/transistor-experiment\/\" data-orig-file=\"https:\/\/i1.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/10\/Transistor-Experiment.png?fit=320%2C390&amp;ssl=1\" data-orig-size=\"320,390\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Transistor Experiment\" data-image-description=\"\" data-medium-file=\"https:\/\/i1.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/10\/Transistor-Experiment.png?fit=246%2C300&amp;ssl=1\" data-large-file=\"https:\/\/i1.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/10\/Transistor-Experiment.png?fit=320%2C390&amp;ssl=1\" loading=\"lazy\" class=\"alignnone size-full wp-image-319\" src=\"https:\/\/i2.wp.com\/einhugur.com\/blog\/wp-content\/uploads\/2015\/10\/Transistor-Experiment.png?resize=320%2C390&#038;ssl=1\" alt=\"Transistor Experiment\" width=\"320\" height=\"390\" srcset=\"https:\/\/i1.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/10\/Transistor-Experiment.png?w=320&amp;ssl=1 320w, https:\/\/i1.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/10\/Transistor-Experiment.png?resize=246%2C300&amp;ssl=1 246w\" sizes=\"(max-width: 320px) 100vw, 320px\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<p><strong>Now we are ready to put this onto the breadboard:<\/strong><\/p>\n<p>We will use GPIO 5 for the GPIO pin.<\/p>\n<p>For the led then you can see in\u00a0the picture bellow then that you have two ways to identify the + and &#8211; or anode vs cathode. Its the length of the pins where the longer wire is the anode and the shorter is the cathode. If wires have been trimmed then you can usually also see it on the LED it self the flat side on the edge is the cathode or &#8211; as is shown on the picture to right here.<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/einhugur.com\/blog\/wp-content\/uploads\/2015\/10\/LED-Explained.png?ssl=1\"><img data-attachment-id=\"225\" data-permalink=\"https:\/\/einhugur.net\/blog\/index.php\/xojo-gpio\/working-with-leds-and-wiring-4-pin-rgb-led-to-raspberry-pi\/led-explained\/\" data-orig-file=\"https:\/\/i2.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/10\/LED-Explained.png?fit=278%2C168&amp;ssl=1\" data-orig-size=\"278,168\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"LED Explained\" data-image-description=\"\" data-medium-file=\"https:\/\/i2.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/10\/LED-Explained.png?fit=278%2C168&amp;ssl=1\" data-large-file=\"https:\/\/i2.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/10\/LED-Explained.png?fit=278%2C168&amp;ssl=1\" loading=\"lazy\" class=\"alignnone size-full wp-image-225\" src=\"https:\/\/i0.wp.com\/einhugur.com\/blog\/wp-content\/uploads\/2015\/10\/LED-Explained.png?resize=278%2C168&#038;ssl=1\" alt=\"LED Explained\" width=\"278\" height=\"168\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<p>When looking up the spec for your transistor then the spec will usually show how the pin layout is so you can know which was it should turn.<\/p>\n<p>For mine it was like this:<\/p>\n<p><a href=\"https:\/\/i1.wp.com\/einhugur.com\/blog\/wp-content\/uploads\/2015\/10\/2N3904.png?ssl=1\"><img data-attachment-id=\"323\" data-permalink=\"https:\/\/einhugur.net\/blog\/index.php\/xojo-gpio\/putting-the-gpio-pin-behind-transistor-to-get-more-current\/2n3904\/\" data-orig-file=\"https:\/\/i1.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/10\/2N3904.png?fit=200%2C145&amp;ssl=1\" data-orig-size=\"200,145\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"2N3904\" data-image-description=\"\" data-medium-file=\"https:\/\/i1.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/10\/2N3904.png?fit=200%2C145&amp;ssl=1\" data-large-file=\"https:\/\/i1.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/10\/2N3904.png?fit=200%2C145&amp;ssl=1\" loading=\"lazy\" class=\"alignnone size-full wp-image-323\" src=\"https:\/\/i1.wp.com\/einhugur.com\/blog\/wp-content\/uploads\/2015\/10\/2N3904.png?resize=200%2C145&#038;ssl=1\" alt=\"2N3904\" width=\"200\" height=\"145\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<p>When putting the parts on the breadboard you should try to go by the circuit drawing instead of blindly following the breadboard drawing since its easier to make mistakes if not understanding the wiring.<\/p>\n<p><a href=\"https:\/\/einhugur.com\/blog\/index.php\/understanding-your-breadboard-and-placement-of-raspberry-cobbler\/\">If you are not familiar with breadboards and placement of the cobbler then check this link out.<\/a><\/p>\n<p><a href=\"https:\/\/i0.wp.com\/einhugur.com\/blog\/wp-content\/uploads\/2015\/10\/TransistorExperimentbb.png?ssl=1\"><img data-attachment-id=\"322\" data-permalink=\"https:\/\/einhugur.net\/blog\/index.php\/xojo-gpio\/putting-the-gpio-pin-behind-transistor-to-get-more-current\/transistorexperimentbb\/\" data-orig-file=\"https:\/\/i0.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/10\/TransistorExperimentbb.png?fit=800%2C565&amp;ssl=1\" data-orig-size=\"800,565\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"TransistorExperimentbb\" data-image-description=\"\" data-medium-file=\"https:\/\/i0.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/10\/TransistorExperimentbb.png?fit=300%2C212&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/10\/TransistorExperimentbb.png?fit=474%2C335&amp;ssl=1\" loading=\"lazy\" class=\"alignnone size-full wp-image-322\" src=\"https:\/\/i0.wp.com\/einhugur.com\/blog\/wp-content\/uploads\/2015\/10\/TransistorExperimentbb.png?resize=474%2C335&#038;ssl=1\" alt=\"TransistorExperimentbb\" width=\"474\" height=\"335\" srcset=\"https:\/\/i0.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/10\/TransistorExperimentbb.png?w=800&amp;ssl=1 800w, https:\/\/i0.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/10\/TransistorExperimentbb.png?resize=300%2C212&amp;ssl=1 300w\" sizes=\"(max-width: 474px) 100vw, 474px\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<h1><a href=\"https:\/\/i0.wp.com\/einhugur.com\/blog\/wp-content\/uploads\/2015\/09\/GPIO-Header.png?ssl=1\"><img data-attachment-id=\"82\" data-permalink=\"https:\/\/einhugur.net\/blog\/index.php\/xojo-gpio\/hc-sr501-sensor\/gpio-header\/\" data-orig-file=\"https:\/\/i2.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/09\/GPIO-Header.png?fit=440%2C870&amp;ssl=1\" data-orig-size=\"440,870\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"GPIO Header\" data-image-description=\"\" data-medium-file=\"https:\/\/i2.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/09\/GPIO-Header.png?fit=152%2C300&amp;ssl=1\" data-large-file=\"https:\/\/i2.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/09\/GPIO-Header.png?fit=440%2C870&amp;ssl=1\" loading=\"lazy\" class=\"size-medium wp-image-82 alignnone\" src=\"https:\/\/i1.wp.com\/einhugur.com\/blog\/wp-content\/uploads\/2015\/09\/GPIO-Header-152x300.png?resize=152%2C300&#038;ssl=1\" alt=\"GPIO Header\" width=\"152\" height=\"300\" srcset=\"https:\/\/i2.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/09\/GPIO-Header.png?resize=152%2C300&amp;ssl=1 152w, https:\/\/i2.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/09\/GPIO-Header.png?w=440&amp;ssl=1 440w\" sizes=\"(max-width: 152px) 100vw, 152px\" data-recalc-dims=\"1\" \/><\/a><\/h1>\n<h1><strong>The Xojo code for this one\u00a0really simple as this was more of electric guide than coding guide<\/strong><\/h1>\n<p>We just had one button on a window with the caption &#8220;Toggle LED&#8221;.<\/p>\n<p>In the window I added the following property:<\/p>\n<pre lang=\"xojo\">Protected ledOn As Boolean = false<\/pre>\n<p><strong>The Window Open event was as follows:<\/strong><\/p>\n<p>The open event of the window:<\/p>\n<pre lang=\"xojo\">Sub Open()\n GPIO.SetupGPIO\n GPIO.PinMode(5,GPIO.OUTPUT)\n GPIO.DigitalWrite(5,GPIO.OFF)\nEnd Sub<\/pre>\n<p><strong>The button\u00a0box event:<\/strong><\/p>\n<pre lang=\"xojo\">Sub Action()\nif ledOn then \nGPIO.DigitalWrite(5,GPIO.OFF)\nledOn = false\nelse \nGPIO.DigitalWrite(5,GPIO.ON)\nledOn = true\nend if\nEnd Sub\n\n<\/pre>\n<h4>Un determined state on the GPIO pin at startup<\/h4>\n<p>Now I was not 100% happy when running it, the LED was on when I booted the computer which is caused by the GPIO pin having undetermined state.<\/p>\n<p>Everything else worked, the code was able to turn it on and off, and the LED was shining bright as it was not having to be conservative on the current it takes.<\/p>\n<p>There was easy fix to that, adding 1k\u03a9 resistor between the GPIO pin and the ground.<\/p>\n<p>Making the circuit like this:<\/p>\n<p><a href=\"https:\/\/i2.wp.com\/einhugur.com\/blog\/wp-content\/uploads\/2015\/10\/Transistor-Experiment-Final.png?ssl=1\"><img data-attachment-id=\"331\" data-permalink=\"https:\/\/einhugur.net\/blog\/index.php\/xojo-gpio\/putting-the-gpio-pin-behind-transistor-to-get-more-current\/transistor-experiment-final\/\" data-orig-file=\"https:\/\/i1.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/10\/Transistor-Experiment-Final.png?fit=329%2C424&amp;ssl=1\" data-orig-size=\"329,424\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Transistor Experiment Final\" data-image-description=\"\" data-medium-file=\"https:\/\/i1.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/10\/Transistor-Experiment-Final.png?fit=233%2C300&amp;ssl=1\" data-large-file=\"https:\/\/i1.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/10\/Transistor-Experiment-Final.png?fit=329%2C424&amp;ssl=1\" loading=\"lazy\" class=\"alignnone size-full wp-image-331\" src=\"https:\/\/i2.wp.com\/einhugur.com\/blog\/wp-content\/uploads\/2015\/10\/Transistor-Experiment-Final.png?resize=329%2C424&#038;ssl=1\" alt=\"Transistor Experiment Final\" width=\"329\" height=\"424\" srcset=\"https:\/\/i1.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/10\/Transistor-Experiment-Final.png?w=329&amp;ssl=1 329w, https:\/\/i1.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/10\/Transistor-Experiment-Final.png?resize=233%2C300&amp;ssl=1 233w\" sizes=\"(max-width: 329px) 100vw, 329px\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<p>After adding the 1k\u03a9 resistor then the LED was shut when batting the computer and it only got turned on and off when sending the signal from the program.<\/p>\n<p>Thats is for now.<\/p>\n<p><code><\/code><code><br \/>\n<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this example we are going to let the GPIO pin control a transistor so that we can draw more power when controlling a LED than what the GPIO pin can supply. We will be using a simple LED in this example where we aim to draw 16 mA power (I could easily go higher &hellip; <a href=\"https:\/\/einhugur.net\/blog\/index.php\/xojo-gpio\/putting-the-gpio-pin-behind-transistor-to-get-more-current\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Putting the GPIO pin behind transistor to get more current<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":94,"menu_order":140,"comment_status":"open","ping_status":"closed","template":"","meta":{"spay_email":""},"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/Pd75nk-51","jetpack-related-posts":[{"id":421,"url":"https:\/\/einhugur.net\/blog\/index.php\/xojo-gpio\/optocouplers\/","url_meta":{"origin":311,"position":0},"title":"Optocouplers","date":"April 18, 2016","format":false,"excerpt":"In this example we are going to take a look at Optocouplers. Disclaimer: We do not take any responsibility for possible errors in the guide or errors that you might do wiring it up. Incorrect wiring can result in damaged sensor or damaged Raspberry PI. Prerequisites: We hight recommend that\u2026","rel":"","context":"Similar post","img":{"alt_text":"Optocoupler","src":"https:\/\/i0.wp.com\/einhugur.com\/blog\/wp-content\/uploads\/2016\/04\/Optocoupler.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":94,"url":"https:\/\/einhugur.net\/blog\/index.php\/xojo-gpio\/","url_meta":{"origin":311,"position":1},"title":"Xojo GPIO","date":"September 19, 2015","format":false,"excerpt":"Guides for GPIO in Xojo \u00a0Infrared motion detection (Updated 1. May 2016) Shows\u00a02 ways of coding: Using Interrupts or simple polling. Sensors: \u00a0HC-SR501,\u00a0ST-00082 Mini,\u00a0Mini IR Pyroelectric Infrared PIR Motion Human Sensor Detector Module Uses:\u00a0Basic GPIO Relay board In this example we \u00a0wire up a relay board and let your Xojo\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":345,"url":"https:\/\/einhugur.net\/blog\/index.php\/xojo-gpio\/using-logic-gates\/","url_meta":{"origin":311,"position":2},"title":"Using logic gates","date":"November 8, 2015","format":false,"excerpt":"In this guide we are going to learn how to use logic gates. \u00a0Even if you can usually do things by just taking more GPIO pins and do the logic in a code then there will be times you may want to do things in hardware. For example you might\u2026","rel":"","context":"Similar post","img":{"alt_text":"LogicCircuits","src":"https:\/\/i2.wp.com\/einhugur.com\/blog\/wp-content\/uploads\/2015\/11\/LogicCircuits.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":102,"url":"https:\/\/einhugur.net\/blog\/index.php\/xojo-gpio\/relay-board\/","url_meta":{"origin":311,"position":3},"title":"Relay board","date":"September 19, 2015","format":false,"excerpt":"In this example we are going to wire up a relay board and let your Xojo code control it. A really board is normally used to control high voltage devices such as lights for example. In my case I will be using them \u00a0to remote control electric heaters in a\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/einhugur.com\/blog\/wp-content\/uploads\/2015\/09\/RelayWiring-300x225.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":224,"url":"https:\/\/einhugur.net\/blog\/index.php\/xojo-gpio\/working-with-leds-and-wiring-4-pin-rgb-led-to-raspberry-pi\/","url_meta":{"origin":311,"position":4},"title":"Working with LED's - And Wiring 4 pin RGB led to Raspberry PI","date":"October 12, 2015","format":false,"excerpt":"In this example we are going\u00a0learn some basics on how to calculate the resistor for LED, and we will take a look at how to wire up a 4 pin RGB LED. Disclaimer: We do not take any responsibility for possible errors in the guide or errors that you might\u2026","rel":"","context":"Similar post","img":{"alt_text":"RGBLedMutimeterTestNew","src":"https:\/\/i1.wp.com\/einhugur.com\/blog\/wp-content\/uploads\/2015\/10\/RGBLedMutimeterTestNew.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":212,"url":"https:\/\/einhugur.net\/blog\/index.php\/xojo-gpio\/connecting-button-with-gpio-and-using-interupts\/","url_meta":{"origin":311,"position":5},"title":"Connecting Button with GPIO and using interupts","date":"October 5, 2015","format":false,"excerpt":"In this example we are going to connect the Raspberry PI with a button, and then make \u00a0Xojo programs where the first one will read from the button without\u00a0interrupts and\u00a0the second will be doing the same using interrupts. Disclaimer: We do not take any responsibility for possible errors in the\u2026","rel":"","context":"With 9 comments","img":{"alt_text":"ButtonWiring","src":"https:\/\/i2.wp.com\/einhugur.com\/blog\/wp-content\/uploads\/2015\/10\/ButtonWiring-e1444085736803.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/einhugur.net\/blog\/index.php\/wp-json\/wp\/v2\/pages\/311"}],"collection":[{"href":"https:\/\/einhugur.net\/blog\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/einhugur.net\/blog\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/einhugur.net\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/einhugur.net\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=311"}],"version-history":[{"count":21,"href":"https:\/\/einhugur.net\/blog\/index.php\/wp-json\/wp\/v2\/pages\/311\/revisions"}],"predecessor-version":[{"id":975,"href":"https:\/\/einhugur.net\/blog\/index.php\/wp-json\/wp\/v2\/pages\/311\/revisions\/975"}],"up":[{"embeddable":true,"href":"https:\/\/einhugur.net\/blog\/index.php\/wp-json\/wp\/v2\/pages\/94"}],"wp:attachment":[{"href":"https:\/\/einhugur.net\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=311"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}