|
<!--| Whatever your mind can conceive and can believe, it can achieve. ~Napoleon Hill
|
|
|
|
| Whatever we think about and thank about we bring about. ~John Demartini
|
|
|
|
| Whether you think you can or can’t either way you are right. ~Henry Ford--><!DOCTYPE html><html class="arduino-html" lang="en"><head><meta charset="utf-8" /><meta content="IE=Edge,chrome=1" http-equiv="X-UA-Compatible" />
|
|
<script type="text/javascript">window.NREUM||(NREUM={});NREUM.info={"beacon":"bam.nr-data.net","errorBeacon":"bam.nr-data.net","licenseKey":"df8ed87324","applicationID":"20455843","transactionName":"IQ0IQ0tXVAhQQx1DRg0IA1RNSxcXXV5F","queueTime":3,"applicationTime":221,"agent":""}</script>
|
|
<script type="text/javascript">window.NREUM||(NREUM={}),__nr_require=function(e,n,t){function r(t){if(!n[t]){var o=n[t]={exports:{}};e[t][0].call(o.exports,function(n){var o=e[t][1][n];return r(o||n)},o,o.exports)}return n[t].exports}if("function"==typeof __nr_require)return __nr_require;for(var o=0;o<t.length;o++)r(t[o]);return r}({1:[function(e,n,t){function r(){}function o(e,n,t){return function(){return i(e,[c.now()].concat(u(arguments)),n?null:this,t),n?void 0:this}}var i=e("handle"),a=e(3),u=e(4),f=e("ee").get("tracer"),c=e("loader"),s=NREUM;"undefined"==typeof window.newrelic&&(newrelic=s);var p=["setPageViewName","setCustomAttribute","setErrorHandler","finished","addToTrace","inlineHit","addRelease"],d="api-",l=d+"ixn-";a(p,function(e,n){s[n]=o(d+n,!0,"api")}),s.addPageAction=o(d+"addPageAction",!0),s.setCurrentRouteName=o(d+"routeName",!0),n.exports=newrelic,s.interaction=function(){return(new r).get()};var m=r.prototype={createTracer:function(e,n){var t={},r=this,o="function"==typeof n;return i(l+"tracer",[c.now(),e,t],r),function(){if(f.emit((o?"":"no-")+"fn-start",[c.now(),r,o],t),o)try{return n.apply(this,arguments)}catch(e){throw f.emit("fn-err",[arguments,this,e],t),e}finally{f.emit("fn-end",[c.now()],t)}}}};a("actionText,setName,setAttribute,save,ignore,onEnd,getContext,end,get".split(","),function(e,n){m[n]=o(l+n)}),newrelic.noticeError=function(e,n){"string"==typeof e&&(e=new Error(e)),i("err",[e,c.now(),!1,n])}},{}],2:[function(e,n,t){function r(e,n){if(!o)return!1;if(e!==o)return!1;if(!n)return!0;if(!i)return!1;for(var t=i.split("."),r=n.split("."),a=0;a<r.length;a++)if(r[a]!==t[a])return!1;return!0}var o=null,i=null,a=/Version\/(\S+)\s+Safari/;if(navigator.userAgent){var u=navigator.userAgent,f=u.match(a);f&&u.indexOf("Chrome")===-1&&u.indexOf("Chromium")===-1&&(o="Safari",i=f[1])}n.exports={agent:o,version:i,match:r}},{}],3:[function(e,n,t){function r(e,n){var t=[],r="",i=0;for(r in e)o.call(e,r)&&(t[i]=n(r,e[r]),i+=1);return t}var o=Object.prototype.hasOwnProperty;n.exports=r},{}],4:[function(e,n,t){function r(e,n,t){n||(n=0),"undefined"==typeof t&&(t=e?e.length:0);for(var r=-1,o=t-n||0,i=Array(o<0?0:o);++r<o;)i[r]=e[n+r];return i}n.exports=r},{}],5:[function(e,n,t){n.exports={exists:"undefined"!=typeof window.performance&&window.performance.timing&&"undefined"!=typeof window.performance.timing.navigationStart}},{}],ee:[function(e,n,t){function r(){}function o(e){function n(e){return e&&e instanceof r?e:e?f(e,u,i):i()}function t(t,r,o,i){if(!d.aborted||i){e&&e(t,r,o);for(var a=n(o),u=v(t),f=u.length,c=0;c<f;c++)u[c].apply(a,r);var p=s[y[t]];return p&&p.push([b,t,r,a]),a}}function l(e,n){h[e]=v(e).concat(n)}function m(e,n){var t=h[e];if(t)for(var r=0;r<t.length;r++)t[r]===n&&t.splice(r,1)}function v(e){return h[e]||[]}function g(e){return p[e]=p[e]||o(t)}function w(e,n){c(e,function(e,t){n=n||"feature",y[t]=n,n in s||(s[n]=[])})}var h={},y={},b={on:l,addEventListener:l,removeEventListener:m,emit:t,get:g,listeners:v,context:n,buffer:w,abort:a,aborted:!1};return b}function i(){return new r}function a(){(s.api||s.feature)&&(d.aborted=!0,s=d.backlog={})}var u="nr@context",f=e("gos"),c=e(3),s={},p={},d=n.exports=o();d.backlog=s},{}],gos:[function(e,n,t){function r(e,n,t){if(o.call(e,n))return e[n];var r=t();if(Object.defineProperty&&Object.keys)try{return Object.defineProperty(e,n,{value:r,writable:!0,enumerable:!1}),r}catch(i){}return e[n]=r,r}var o=Object.prototype.hasOwnProperty;n.exports=r},{}],handle:[function(e,n,t){function r(e,n,t,r){o.buffer([e],r),o.emit(e,n,t)}var o=e("ee").get("handle");n.exports=r,r.ee=o},{}],id:[function(e,n,t){function r(e){var n=typeof e;return!e||"object"!==n&&"function"!==n?-1:e===window?0:a(e,i,function(){return o++})}var o=1,i="nr@id",a=e("gos");n.exports=r},{}],loader:[function(e,n,t){function r(){if(!E++){var e=x.info=NREUM.info,n=l.getElementsByTagName("script")[0];if(setTimeout(s.abort,3e4),!(e&&e.licenseKey&&e.applicationID&&n))return s.abort();c(y,function(n,t){e[n]||(e[n]=t)}),f("mark",["onload",a()+x.offset],null,"api");var t=l.createElement("script");t.src="https://"+e.agent,n.parentNode.insertBefore(t,n)}}function o(){"complete"===l.readyState&&i()}function i(){f("mark",["domContent",a()+x.offset],null,"api")}function a(){return O.exists&&performance.now?Math.round(performance.now()):(u=Math.max((new Date).getTime(),u))-x.offset}var u=(new Date).getTime(),f=e("handle"),c=e(3),s=e("ee"),p=e(2),d=window,l=d.document,m="addEventListener",v="attachEvent",g=d.XMLHttpRequest,w=g&&g.prototype;NREUM.o={ST:setTimeout,SI:d.setImmediate,CT:clearTimeout,XHR:g,REQ:d.Request,EV:d.Event,PR:d.Promise,MO:d.MutationObserver};var h=""+location,y={beacon:"bam.nr-data.net",errorBeacon:"bam.nr-data.net",agent:"js-agent.newrelic.com/nr-1118.min.js"},b=g&&w&&w[m]&&!/CriOS/.test(navigator.userAgent),x=n.exports={offset:u,now:a,origin:h,features:{},xhrWrappable:b,userAgent:p};e(1),l[m]?(l[m]("DOMContentLoaded",i,!1),d[m]("load",r,!1)):(l[v]("onreadystatechange",o),d[v]("onload",r)),f("mark",["firstbyte",u],null,"api");var E=0,O=e(5)},{}]},{},["loader"]);</script><meta content="414718878625776" property="fb:app_id" /><meta content="width=device-width, initial-scale=1.0" name="viewport" /><meta content="arduino-api.hackster.io" id="api-uri" name="api-uri" /><meta content="/projecthub" id="path-prefix" name="path-prefix" /><title>Fade LED without using PWM - Arduino Project Hub</title><meta content="Demonstration of fading an LED that is not connected to a PWM pin." name="description" /><meta name="csrf-param" content="authenticity_token" />
|
|
<meta name="csrf-token" content="MX9NdxtIhMxfKIR0t38bv8p0hUGf45L+24SwycP0zWFpmvvcFPofbYx84KBWqi4YAN0ExdS9tRcj0uGlJORaDQ==" /><!--Le HTML5 shim, for IE6-8 support of HTML elements--><!--[if lt IE 9]
|
|
= javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.6.1/html5shiv.js"--><link rel="stylesheet" media="all" href="/assets/application-13603406ad561111bef6776ce00f30f7df9527d110faada92aa4fcb9681ccfff.css" /><link href="https://halckemy.s3.amazonaws.com/uploads/favicon/file/103324/FaviconB.ico" rel="shortcut icon" /><meta content="Arduino Project Hub" name="apple-mobile-web-app-title" /><meta content="Arduino Project Hub" name="application-name" /><script>
|
|
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
|
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
|
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
|
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
|
|
|
ga('create', 'UA-22581631-11', 'auto');
|
|
ga('send', 'pageview');
|
|
|
|
</script><script>gglTagMngrDataLayer = [{
|
|
'loggedIn': "false",
|
|
'pageType': "projects#show",
|
|
'virtualPageview': "false"
|
|
}];</script><script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
|
|
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
|
|
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
|
|
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
|
|
})(window,document,'script','gglTagMngrDataLayer','GTM-KR3BZMN');</script><meta content="Fade LED without using PWM" property="og:title" /><meta content="Demonstration of fading an LED that is not connected to a PWM pin. By chip1264." property="og:description" /><meta content="https://create.arduino.cc/assets/whitelabel/arduino/placeholder_proj_cover-b2c93bbd904e5a7da1bf7ecd993fa0d39171960224b84cea8b23dbd5a7ea5df6.svg" property="og:image" /><meta content="600" property="og:image:width" /><meta content="450" property="og:image:height" /><meta content="https://create.arduino.cc/projecthub/hs_education_georgia/fade-led-without-using-pwm-08a82f?use_route=project" property="og:url" /><meta content="summary_large_image" property="twitter:card" /><meta content="Fade LED without using PWM" property="twitter:title" /><meta content="Demonstration of fading an LED that is not connected to a PWM pin." property="twitter:description" /><meta content="https://create.arduino.cc/assets/whitelabel/arduino/placeholder_proj_cover-b2c93bbd904e5a7da1bf7ecd993fa0d39171960224b84cea8b23dbd5a7ea5df6.svg" property="twitter:image" /><link href="https://www.hackster.io/hs_education_georgia/fade-led-without-using-pwm-08a82f?use_route=project" rel="canonical" /><meta content="fade,lights,pwm" name="keywords" /><meta content="@arduino" property="twitter:site" /><meta content="create.arduino.cc" property="twitter:domain" /><meta content="Arduino Project Hub" property="og:site_name" /><style type="text/css">.arduino-projects {
|
|
background-color: #00979C;
|
|
}
|
|
a:hover {
|
|
text-decoration: none;
|
|
}
|
|
#page {
|
|
padding: 0 !important;
|
|
}
|
|
.navbar-static-top {
|
|
z-index: 10;
|
|
}
|
|
.top-bar, .top-bar a {
|
|
font-weight: bold;
|
|
}
|
|
.row .row.collapse:before, .row .row.collapse:after {
|
|
content: " ";
|
|
display: table; }
|
|
.row .row.collapse:after {
|
|
clear: both; }
|
|
@media (min-width: 1200px) {
|
|
.navbar-in .container {
|
|
max-width: 990px;
|
|
}
|
|
}
|
|
body.whitelabel .powered-by {
|
|
padding: 20px 0;
|
|
}
|
|
.thumb-inner {
|
|
padding: 10px 20px;
|
|
height: 150px;
|
|
position: relative;
|
|
}
|
|
.thumb-inner h4 {
|
|
margin-top: 0;
|
|
}
|
|
.thumb-inner .project-stats {
|
|
position: absolute;
|
|
bottom: 10px;
|
|
width: 100%;
|
|
left: 0;
|
|
margin: 0;
|
|
padding: 0 15px;
|
|
}
|
|
.arduino-html .alert.alert-top {
|
|
font-size: 11.5px;
|
|
top: 104px;
|
|
}
|
|
#outer-wrapper {
|
|
margin-bottom: -120px;
|
|
padding-bottom: 120px;
|
|
}</style><link rel="stylesheet" media="screen" href="/assets/whitelabel/arduino/application-ff4249d34d0a550d698f91de3a36b25dc655b26f960f0605814668df0599ee2b.css" /><!-- Global Site Tag (gtag.js) - Google Analytics -->
|
|
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-22581631-3"></script>
|
|
<script>
|
|
window.dataLayer = window.dataLayer || [];
|
|
function gtag(){dataLayer.push(arguments)};
|
|
gtag('js', new Date());
|
|
gtag('config', 'UA-22581631-3');
|
|
</script>
|
|
<link rel="stylesheet" href="https://cdn.arduino.cc/projecthub/css/arduino_application.css"><script>window.defaultAvatarUrl = 'https://dcw9y8se13llu.cloudfront.net/avatars/default.svg';
|
|
function showDefaultAvatar(img){
|
|
img.src = window.defaultAvatarUrl;
|
|
}</script><script src="/assets/application-2d267efbbb7ade1022cd22bce2084b53195f01cef5a4ff1fd01a4e137fc2724d.js"></script></head><body class="whitelabel"><div id="outer-wrapper"><div class="popup-overlay modal-popup" data-width="450" id="simplified-signup-popup"><div class="popup-overlay-bg"></div><div class="popup-overlay-outer"><div class="popup-overlay-inner"><button class="close" data-target="#simplified-signup-popup">×</button><h4>Please sign in to continue:</h4><a class="btn btn-primary" href="https://www.hackster.io/users/auth/arduino?current_site=arduino&setup=true&redirect_to=%2Fprojecthub%2Fhs_education_georgia%2Ffade-led-without-using-pwm-08a82f">Sign in</a></div></div></div><div id="sign_in_container"><a class="login-link" href="https://www.hackster.io/users/auth/arduino?current_site=arduino&setup=true&redirect_to=%2Fprojecthub%2Fhs_education_georgia%2Ffade-led-without-using-pwm-08a82f">Sign In</a></div><div class="hidden"><a id="user-signin-signout" href="https://www.hackster.io/users/auth/arduino?current_site=arduino&setup=true&redirect_to=%2Fprojecthub%2Fhs_education_georgia%2Ffade-led-without-using-pwm-08a82f"><button>Sign In</button></a></div><div class="arduino-bbq">
|
|
|
|
<div id="create-nav"></div>
|
|
|
|
<div class="navbar navbar-default navbar-static-top" id="navigation">
|
|
<div class="navbar-in" style="position:relative;">
|
|
|
|
<a class="create-logo" href="/projecthub"></a>
|
|
|
|
<div class="pull-right" id="navbar-search">
|
|
<form action="/projecthub/search" class="navbar-form" method="get">
|
|
<div class="form-group">
|
|
<div class="input-group">
|
|
<span class="input-group-addon">
|
|
<i class="fa fa-search"></i>
|
|
</span>
|
|
<input class="form-control" id="q" name="q" placeholder="Search projects" type="text">
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<div class="pull-right" style="padding-top: 11px;">
|
|
<a class="btn btn-primary logged-out" id="my_dashboard">
|
|
<span>My dashboard</span>
|
|
</a>
|
|
<a class="btn btn-primary" id="add_project" href="/projecthub/projects/new">
|
|
<span class="text">Add project</span>
|
|
<span class="icon-minified"></span>
|
|
</a>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="filler-bg-toolbar"></div>
|
|
</div><div id="main"><a class="project-switcher previous istooltip" data-container="body" data-placement="right" href="/projecthub/projects/08a82f/next?dir=prev" rel="nofollow tooltip" title="Previous project"><div class="inner"><i class="fa fa-chevron-left"></i></div></a><a class="project-switcher next istooltip" data-container="body" data-placement="left" href="/projecthub/projects/08a82f/next?dir=next" rel="nofollow tooltip" title="Next project"><div class="inner"><i class="fa fa-chevron-right"></i></div></a><div class="popup-overlay modal-popup" id="embed-popup"><div class="popup-overlay-bg"></div><div class="popup-overlay-outer"><div class="popup-overlay-inner"><button class="close unselectable" data-effect="fade" data-target="#embed-popup">×</button><h3 class="top">Share</h3><!-- AddThis Button BEGIN --><div class="addthis_toolbox addthis_default_style addthis_32x32_style"><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div><!-- AddThis Button END --><div class="add-to-list"></div><h3>Embed the widget on your own site</h3><div id="project-embed"><p>Add the following snippet to your HTML:<input class="embed-code" onclick="this.select();" type="text" value="<iframe frameborder='0' height='410' scrolling='no' src='https://create.arduino.cc/projecthub/hs_education_georgia/fade-led-without-using-pwm-08a82f/embed?use_route=project' width='360' style='margin-top:30px'></iframe>" /></p><div class="row"><div class="project-embed-thumb col-sm-6 col-md-4 "><div class="project-thumb-container"><div class="project-18672"><div class="thumb project-thumb"><div class="thumb-image has-link-overlay"><img alt="Fade LED without using PWM" class="project-thumb-img loaded" src="https://create.arduino.cc/assets/whitelabel/arduino/placeholder_proj_cover-b2c93bbd904e5a7da1bf7ecd993fa0d39171960224b84cea8b23dbd5a7ea5df6.svg" /><a class="link-overlay project-link-with-ref" target="_blank" href="https://create.arduino.cc/projecthub/hs_education_georgia/fade-led-without-using-pwm-08a82f?use_route=project"></a><div class="thumb-image-inner-top"><div class="award-container"></div><p class="description show-on-hover">Demonstration of fading an LED that is not connected to a PWM pin.</p></div><div class="thumb-image-inner"><h4><a class="project-link-with-ref" target="_blank" href="https://create.arduino.cc/projecthub/hs_education_georgia/fade-led-without-using-pwm-08a82f?use_route=project">Fade LED without using PWM</a> </h4><p>Project showcase by <a class="user-name" target="_blank" href="https://create.arduino.cc/projecthub/teams/hs_education_georgia">HS_Education_Georgia</a></p><ul class="list-inline project-stats"><li><span class="stat-figure">3,625</span> views</li><li><span class="stat-figure">0</span> comments</li><li><span class="stat-figure">3</span> respects</li></ul></div><div class="thumb-super"></div></div></div></div></div></div></div><div class="clearfix"></div></div></div></div></div><!-- AddThis Button BEGIN --><script>var addthis_share = {
|
|
"data_track_addressbar":false,
|
|
url: "https://create.arduino.cc/projecthub/hs_education_georgia/fade-led-without-using-pwm-08a82f?use_route=project",
|
|
title: "Cool stuff: Fade LED without using PWM by chip1264"
|
|
};</script><!-- AddThis Button END --><script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-51b26f5613fb83d2" async="async"></script><div class="project-page project-18672" id="content"><div class="container-desktop container"><div class="info-header">Project showcase</div><div class="row"><div class="col-md-8 left-column"><div class="project-banner" id="home"><img alt="Fade LED without using PWM" src="https://create.arduino.cc/assets/whitelabel/arduino/placeholder_proj_cover-b2c93bbd904e5a7da1bf7ecd993fa0d39171960224b84cea8b23dbd5a7ea5df6.svg" /></div><div class="project-banner-inner"><h1 class="project-title">Fade LED without using PWM <a class="copyright" href="http://opensource.org/licenses/GPL-3.0" target="_blank">© GPL3+</a></h1><p class="project-one-liner">Demonstration of fading an LED that is not connected to a PWM pin.</p><ul class="list-inline tags"><li><a class="tag" href="/projecthub/projects/tags/fade">fade</a></li><li><a class="tag" href="/projecthub/projects/tags/lights">lights</a></li><li><a class="tag" href="/projecthub/projects/tags/pwm">pwm</a></li></ul><ul class="list-inline project-stats"><li class="impression-stats"><span class="stat-figure">3,530</span> views</li><li class="comment-stats"><span class="stat-figure">0</span> comments</li><li class="respect-stats"><span class="stat-figure">3</span> respects</li></ul></div><section class="section-container section-collapsible" id="components"><h2 class="section-title"><span class="title title-toggle"><a class="title-anchor" href="#components"><i class="fa fa-link"></i></a><span>Components and supplies</span><i class="fa fa-chevron-down"></i><i class="fa fa-chevron-up"></i></span></h2><div class="section-content"><table class="sortable-table table table-hover fields-container parts-table"><tbody><tr class="fields part-row" id="part-8233"><td class="part-img"><a target="_blank" rel="nofollow noopener" href="/projecthub/products/buy/41?s=BAhJIhYxODY3MixCYXNlQXJ0aWNsZQY6BkVG%0A"><img src="https://hackster.imgix.net/uploads/image/file/160542/A000066_iso_both.jpg?auto=compress%2Cformat&w=140&h=140&fit=fill&bg=ffffff" alt="A000066 iso both" /></a></td><td><table class="part-body" style="width:100%"><tbody><tr class="part-name"><td><a target="_blank" rel="nofollow noopener" href="/projecthub/products/buy/41?s=BAhJIhYxODY3MixCYXNlQXJ0aWNsZQY6BkVG%0A">Arduino UNO & Genuino UNO</a></td></tr><tr class="part-comment"><td style="color: #888;font-size:75%;"></td></tr></tbody></table></td><td style="width:30px;text-align:center;vertical-align:middle"><a target="_blank" rel="nofollow noopener" href="/projecthub/products/buy/41?s=BAhJIhYxODY3MixCYXNlQXJ0aWNsZQY6BkVG%0A">×</a></td><td style="width:10%;min-width:20px;text-align:center;vertical-align:middle"><a target="_blank" rel="nofollow noopener" href="/projecthub/products/buy/41?s=BAhJIhYxODY3MixCYXNlQXJ0aWNsZQY6BkVG%0A">1</a></td><td style="vertical-align:middle"><a target="_blank" style="color:#333" rel="nofollow noopener" href="/projecthub/products/buy/41?s=BAhJIhYxODY3MixCYXNlQXJ0aWNsZQY6BkVG%0A"><i class="fa fa-shopping-cart"></i></a></td></tr></tbody></table></div></section><section class="section-container section-collapsible" id="apps"><h2 class="section-title"><span class="title title-toggle"><a class="title-anchor" href="#apps"><i class="fa fa-link"></i></a><span>Apps and online services</span><i class="fa fa-chevron-down"></i><i class="fa fa-chevron-up"></i></span></h2><div class="section-content"><table class="sortable-table table table-hover fields-container parts-table"><tbody><tr class="fields part-row" id="part-10308"><td class="part-img"><a target="_blank" rel="nofollow noopener" href="https://www.arduino.cc/en/main/software"><img src="https://hackster.imgix.net/uploads/image/file/144203/IDE_web.jpg?auto=compress%2Cformat&w=140&h=140&fit=fill&bg=ffffff" alt="Ide web" /></a></td><td><table class="part-body" style="width:100%"><tbody><tr class="part-name"><td><a target="_blank" rel="nofollow noopener" href="https://www.arduino.cc/en/main/software">Arduino IDE</a></td></tr><tr class="part-comment"><td style="color: #888;font-size:75%;"></td></tr></tbody></table></td><td style="vertical-align:middle"><a target="_blank" style="color:#333" rel="noopener nofollow" href="https://www.arduino.cc/en/main/software"><i class="fa fa-link"></i></a></td></tr></tbody></table></div></section><section class="section-container section-collapsible" id="about-project"><h2 class="section-title"><span class="title title-toggle"><a class="title-anchor" href="#about-project"><i class="fa fa-link"></i></a><span>About this project</span><i class="fa fa-chevron-down"></i><i class="fa fa-chevron-up"></i></span></h2><div class="section-content hljs-active hljs-arduino"><div class="medium-editor"><p data-hash='aKW3'>I wanted to be able to control the brightness of the LED on pin 13 knowing it is not a PWM connected pin. On some of my boards, this LED is quite bright and I would rather have it fade instead of blink.</p></div></div></section><section class="section-container section-collapsible" id="code"><h2 class="section-title"><span class="title title-toggle"><a class="title-anchor" href="#code"><i class="fa fa-link"></i></a><span>Code</span><i class="fa fa-chevron-down"></i><i class="fa fa-chevron-up"></i></span></h2><div class="section-content"><div class="code-widgets single-file "><div class="sidebar"><ul><li><a data-target="#code-widget-57794" class="active" href="javascript:void(0)">FadeWithoutPWM</a></li></ul></div><div class="preview-container"><div class="preview-pane active" id="code-widget-57794"><div class="preview-header"><div class="clearfix"><h5>FadeWithoutPWM<small>Arduino</small></h5><div class="buttons btn-group btn-group-default"><button class="btn btn-primary btn-xs copy-code istooltip" data-container="body" data-trigger="hover" title="Copy the code"><i class="fa fa-clipboard"></i></button><a class="btn btn-primary btn-xs" data-container="body" href="/projecthub/code_files/57794/download" rel="tooltip" title="Download"><i class="fa fa-cloud-download"></i></a></div></div><div class="comment">Example of fading an LED without it being connected to a PWM pin</div></div><div class="preview-body pygments-syntax arduino"><div class="highlight"><pre><span id="line-1"><span class="cm">/* fade w/o pwm</span>
|
|
</span><span id="line-2"><span class="cm"> </span>
|
|
</span><span id="line-3"><span class="cm">Fades an LED that is not connected to a PWM pin</span>
|
|
</span><span id="line-4"><span class="cm">This was modified from the Blink without Delay code</span>
|
|
</span><span id="line-5"><span class="cm"> </span>
|
|
</span><span id="line-6"><span class="cm"> The circuit:</span>
|
|
</span><span id="line-7"><span class="cm"> * LED attached from pin 13 to ground.</span>
|
|
</span><span id="line-8"><span class="cm"> * Note: on most Arduinos, there is already an LED on the board</span>
|
|
</span><span id="line-9"><span class="cm"> that's attached to pin 13, so no hardware is needed for this example.</span>
|
|
</span><span id="line-10"><span class="cm"> </span>
|
|
</span><span id="line-11"><span class="cm"> */</span>
|
|
</span><span id="line-12">
|
|
</span><span id="line-13"><span class="c1">// constants won't change. Used here to set pin numbers:</span>
|
|
</span><span id="line-14"><span class="kr">const</span> <span class="kr">int</span> <span class="n">ledPin</span> <span class="o">=</span> <span class="mi">13</span><span class="p">;</span> <span class="c1">// the number of the LED pin</span>
|
|
</span><span id="line-15">
|
|
</span><span id="line-16"><span class="c1">// Variables will change:</span>
|
|
</span><span id="line-17"><span class="kr">int</span> <span class="n">ledState</span> <span class="o">=</span> <span class="kr">LOW</span><span class="p">;</span> <span class="c1">// ledState used to set the LED</span>
|
|
</span><span id="line-18"><span class="kr">long</span> <span class="n">previousMicros</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="c1">// will store the last time the blink cycle occured</span>
|
|
</span><span id="line-19">
|
|
</span><span id="line-20"><span class="c1">// the follow variables is a long because the time, measured in microseconds,</span>
|
|
</span><span id="line-21"><span class="c1">// will quickly become a bigger number than can be stored in an int.</span>
|
|
</span><span id="line-22"><span class="kr">long</span> <span class="n">intervalLength</span> <span class="o">=</span> <span class="mi">500</span><span class="p">;</span> <span class="c1">// interval at which to blink (microseconds)</span>
|
|
</span><span id="line-23"><span class="kr">long</span> <span class="n">onInterval</span> <span class="o">=</span> <span class="mi">20</span><span class="p">;</span> <span class="c1">// on or HIGH interval length</span>
|
|
</span><span id="line-24"><span class="kr">long</span> <span class="n">currentInterval</span><span class="p">;</span> <span class="c1">// length of the current interval</span>
|
|
</span><span id="line-25"><span class="kr">int</span> <span class="n">fadeLength</span> <span class="o">=</span> <span class="mi">200</span><span class="p">;</span>
|
|
</span><span id="line-26"><span class="kr">int</span> <span class="n">fadeCount</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
|
|
</span><span id="line-27"><span class="kr">int</span> <span class="n">intervalDirection</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span>
|
|
</span><span id="line-28">
|
|
</span><span id="line-29"><span class="kr">void</span> <span class="nb">setup</span><span class="p">()</span> <span class="p">{</span>
|
|
</span><span id="line-30"> <span class="c1">// set the digital pin as output:</span>
|
|
</span><span id="line-31"> <span class="nf">pinMode</span><span class="p">(</span><span class="n">ledPin</span><span class="p">,</span> <span class="kr">OUTPUT</span><span class="p">);</span>
|
|
</span><span id="line-32"><span class="p">}</span>
|
|
</span><span id="line-33">
|
|
</span><span id="line-34"><span class="kr">void</span> <span class="nb">loop</span><span class="p">()</span>
|
|
</span><span id="line-35"><span class="p">{</span>
|
|
</span><span id="line-36">
|
|
</span><span id="line-37"> <span class="kr">unsigned</span> <span class="kr">long</span> <span class="n">currentMicros</span> <span class="o">=</span> <span class="nf">micros</span><span class="p">();</span>
|
|
</span><span id="line-38">
|
|
</span><span id="line-39"> <span class="n">currentInterval</span> <span class="o">=</span> <span class="n">currentMicros</span> <span class="o">-</span> <span class="n">previousMicros</span><span class="p">;</span>
|
|
</span><span id="line-40">
|
|
</span><span id="line-41"> <span class="k">if</span> <span class="p">(</span><span class="n">currentInterval</span> <span class="o"><=</span> <span class="n">onInterval</span><span class="p">)</span> <span class="p">{</span>
|
|
</span><span id="line-42"> <span class="n">ledState</span> <span class="o">=</span> <span class="kr">HIGH</span><span class="p">;</span>
|
|
</span><span id="line-43"> <span class="p">}</span>
|
|
</span><span id="line-44"> <span class="k">else</span> <span class="p">{</span>
|
|
</span><span id="line-45"> <span class="n">ledState</span> <span class="o">=</span> <span class="kr">LOW</span><span class="p">;</span>
|
|
</span><span id="line-46"> <span class="p">}</span>
|
|
</span><span id="line-47">
|
|
</span><span id="line-48"> <span class="k">if</span><span class="p">(</span><span class="n">currentInterval</span> <span class="o">></span> <span class="n">intervalLength</span><span class="p">)</span> <span class="p">{</span>
|
|
</span><span id="line-49"> <span class="c1">// save the last time you blinked the LED </span>
|
|
</span><span id="line-50"> <span class="n">previousMicros</span> <span class="o">=</span> <span class="n">currentMicros</span><span class="p">;</span>
|
|
</span><span id="line-51"> <span class="n">fadeCount</span><span class="o">++</span><span class="p">;</span>
|
|
</span><span id="line-52"> <span class="k">if</span> <span class="p">(</span><span class="n">fadeCount</span> <span class="o">></span> <span class="n">fadeLength</span><span class="p">)</span> <span class="p">{</span>
|
|
</span><span id="line-53"> <span class="n">fadeCount</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
|
|
</span><span id="line-54"> <span class="n">onInterval</span> <span class="o">+=</span> <span class="p">(</span><span class="n">intervalDirection</span> <span class="o">*</span> <span class="mi">20</span><span class="p">);</span>
|
|
</span><span id="line-55"> <span class="k">if</span> <span class="p">(</span><span class="n">onInterval</span> <span class="o"><=</span> <span class="mi">20</span> <span class="o">||</span> <span class="n">onInterval</span> <span class="o">>=</span> <span class="n">intervalLength</span><span class="p">)</span> <span class="p">{</span>
|
|
</span><span id="line-56"> <span class="n">intervalDirection</span> <span class="o">*=</span> <span class="o">-</span><span class="mi">1</span><span class="p">;</span> <span class="c1">// change the direction of the fade ( positive - brighter / negative - dimmer)</span>
|
|
</span><span id="line-57"> <span class="p">}</span>
|
|
</span><span id="line-58"> <span class="p">}</span>
|
|
</span><span id="line-59"> <span class="p">}</span>
|
|
</span><span id="line-60">
|
|
</span><span id="line-61"> <span class="c1">// set the LED with the ledState of the variable:</span>
|
|
</span><span id="line-62"> <span class="nf">digitalWrite</span><span class="p">(</span><span class="n">ledPin</span><span class="p">,</span> <span class="n">ledState</span><span class="p">);</span>
|
|
</span><span id="line-63"><span class="p">}</span>
|
|
</span></pre></div></div></div></div></div></div></section><section class="section-container section-collapsible" id="schematics"><h2 class="section-title"><span class="title title-toggle"><a class="title-anchor" href="#schematics"><i class="fa fa-link"></i></a><span>Schematics</span><i class="fa fa-chevron-down"></i><i class="fa fa-chevron-up"></i></span></h2><div class="section-content"><div class="repository"><div class="button-content-container"><div class="button-content"><h5>FadeWithoutPWM</h5><div class="buttons"><a class="btn btn-primary btn-sm" href="https://halckemy.s3.amazonaws.com/uploads/document/file/140945/FadeWithoutPWM.fzz">Download </a></div></div></div><div class="comment">Arduino board with built-in LED on pin 13.</div><div class="document-widget"><div class="file"><i class="fa fa-file-o fa-lg"></i><span>FadeWithoutPWM.fzz</span></div></div></div></div></section><section class="section-container section-collapsible" id="comments"><h2 class="section-title"><span class="title title-toggle"><a class="title-anchor" href="#comments"><i class="fa fa-link"></i></a><span>Comments</span><i class="fa fa-chevron-down"></i><i class="fa fa-chevron-up"></i></span></h2><div class="section-content"><div class="comments"><div class="user-signed-out" style="display:none"><p class="sign-up-to-comment">Please <a href="/projecthub/users/sign_in?id=18672&m=base_article&reason=comment&redirect_to=%2Fprojecthub%2Fhs_education_georgia%2Ffade-led-without-using-pwm-08a82f%23comments">log in</a> or <a href="/projecthub/users/sign_up?id=18672&m=base_article&reason=comment&redirect_to=%2Fprojecthub%2Fhs_education_georgia%2Ffade-led-without-using-pwm-08a82f%23comments&source=popup">sign up</a> to comment.</p></div><div data-react-class="Comments" data-react-props="{"commentable":{"id":"08a82f","type":"projects"},"placeholder":"Share your thoughts! What do you like about this project? How could it be improved? Be respectful and constructive – most Hackster members create and share personal projects in their free time.","cacheVersion":"arduino"}"></div></div></div></section></div><div class="col-md-4 right-column"><div class="container-mobile"><section class="section-thumbs" id="team"><h4><a href="/projecthub/teams/hs_education_georgia">Team HS_Education_Georgia</a></h4><div class="thumb wide-thumb clearfix"><a href="/projecthub/chip1264"><img class="media-object" onerror="javascript:showDefaultAvatar(this);" src="https://dcw9y8se13llu.cloudfront.net/avatars/chip1264.jpg" alt="Chip1264" /></a><div class="wide-thumb-body"><h5><a href="/projecthub/chip1264">chip1264</a> <small><i class="fa fa-info-circle ispopover" data-container="body" data-content="Creator" data-placement="top" data-title="Contribution" data-trigger="hover"></i></small></h5><ul class="project-stats list-inline"><li><strong>1</strong> project </li><li><strong>0</strong> followers </li></ul><div class="wide-thumb-body-bottom"><a class="follow-button btn btn-secondary btn-sm btn-shorter show-simplified-signup" data-redirect-to="/projecthub/followers/create?followable_id=69791&followable_type=User&source=projects%23show" data-source="follow_user" href="/projecthub/users/sign_up?id=69791&m=user&reason=follow&redirect_to=%2Fprojecthub%2Ffollowers%2Fcreate%3Ffollowable_id%3D69791%26followable_type%3DUser">Follow</a></div></div></div></section><section class="section-thumbs"><div class="project-actions"><div class="mg-10"><a class="respect-button btn btn-block btn-ellipsis btn-primary show-simplified-signup base_article-18672-respect" data-container="body" data-redirect-to="/projecthub/articles/08a82f/respects/create" data-source="respect_project" href="/projecthub/users/sign_up?id=18672&m=article&reason=respect&redirect_to=%2Fprojecthub%2Farticles%2F08a82f%2Frespects%2Fcreate"><i class="fa fa-thumbs-o-up"></i><span>Respect project</span></a></div><a class="btn btn-secondary btn-sm smooth-scroll give-feedback" data-offset="-70" href="#comments"><i class="fa fa-pencil-square-o"></i><span>Write a comment</span></a><div class="text-center" style="position:relative"><a data-target="#embed-popup" class="btn btn-link btn-sm modal-open" href="#"><i class="fa fa-share-square-o"></i><span>Share</span></a></div></div></section><section class="section-thumbs"><h4>Members who respect this project</h4><div class="project-widget-with-user-thumbs"><div class="user-thumbs clearfix"><a data-container="body" rel="tooltip" title="Jerry Wang" href="/projecthub/en0669"><img class="img-responsive user-img img-rounded" onerror="javascript:showDefaultAvatar(this);" src="https://dcw9y8se13llu.cloudfront.net/avatars/default.svg" alt="Default" /></a></div><p class="others-count">and 2 others</p></div></section><section class="section-thumbs hidden-xs hidden-sm affixable" data-top="50" id="project-side-nav" style="top:50px"><h4>Table of contents</h4><div class="section-container" id="scroll-nav"><ul class="nav"><li class="active"><a class="smooth-scroll" data-offset="-40" href="#content">Sound monitoring system</a></li><li><a class="smooth-scroll" data-offset="-70" href="#components">Components and supplies</a></li><li><a class="smooth-scroll" data-offset="-70" href="#apps">Apps and online services</a></li><li><a class="smooth-scroll" data-offset="-70" href="#about-project">About this project</a></li><li><a class="smooth-scroll" data-offset="-70" href="#code">Code</a></li><li><a class="smooth-scroll" data-offset="-70" href="#schematics">Schematics</a></li><li><a class="smooth-scroll" data-offset="-70" href="#comments">Comments<span class="nav-count">(2)</span></a></li></ul></div><div class="show-on-affix" style="margin-top:20px;"><div class="project-actions"><div class="mg-10"><a class="respect-button btn btn-block btn-ellipsis btn-primary show-simplified-signup base_article-18672-respect" data-container="body" data-redirect-to="/projecthub/articles/08a82f/respects/create" data-source="respect_project" href="/projecthub/users/sign_up?id=18672&m=article&reason=respect&redirect_to=%2Fprojecthub%2Farticles%2F08a82f%2Frespects%2Fcreate"><i class="fa fa-thumbs-o-up"></i><span>Respect project</span></a></div><a class="btn btn-secondary btn-sm smooth-scroll give-feedback" data-offset="-70" href="#comments"><i class="fa fa-pencil-square-o"></i><span>Write a comment</span></a><div class="text-center" style="position:relative"><a data-target="#embed-popup" class="btn btn-link btn-sm modal-open" href="#"><i class="fa fa-share-square-o"></i><span>Share</span></a></div></div></div></section></div></div></div></div></div></div></div><div id="mini-footer"><a class="logoArduinoGenuino" href="https://www.arduino.cc"></a><p>Powered by<br><a id="hackster-logo" href="https://www.hackster.io"></a></p></div><div class="popup-overlay modal-popup" data-width="450" id="login-popup"><div class="popup-overlay-bg"></div><div class="popup-overlay-outer"><div class="popup-overlay-inner"><button class="close" data-target="#login-popup">×</button><h4>Good to see you again</h4><form class="simple_form form-compact disable-on-submit user-form" id="login-form" novalidate="novalidate" action="/projecthub/users/sign_in?redirect_to=%2Fprojecthub%2Fhs_education_georgia%2Ffade-led-without-using-pwm-08a82f" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="✓" /><div class="form-group email optional user_email"><input class="string email optional form-control form-control" autofocus="autofocus" maxlength="255" placeholder="Email" type="email" size="255" value="" name="user[email]" id="user_email" /></div><div class="form-group password optional user_password"><input class="password optional form-control" maxlength="128" placeholder="Password" size="128" type="password" name="user[password]" id="user_password" /></div><div class="form-group boolean optional user_remember_me"><input value="0" type="hidden" name="user[remember_me]" /><label class="checkbox"><input class="boolean optional" type="checkbox" value="1" checked="checked" name="user[remember_me]" id="user_remember_me" /> Keep me signed in on this device</label></div><input class="btn-block btn btn-primary" type="submit" value="Log into my Hackster.io account" /><a class="forgot-pass" href="/projecthub/users/password/new">Forgot your password?</a></form><hr /><div class="social-icons text-center"><p class="text-muted"><small>Or connect with your social account:</small></p><a class="zocial icon email" href="https://www.hackster.io/users/auth/arduino?path_prefix=projecthub&redirect_host=create.arduino.cc&redirect_to=%2Fprojecthub%2Fhs_education_georgia%2Ffade-led-without-using-pwm-08a82f">Login with Arduino</a></div><hr /><p><small>New here? <a href="/projecthub/users/sign_up">Create an account</a></small></p></div></div></div><div class="hide-on-desktop" id="mobile-nav-overlay"><div class="fa fa-times" id="mobile-nav-overlay-close"></div></div><div class="hide-on-desktop" id="mobile-navigation"><form action="/projecthub/search" class="navbar-form" method="get"><div class="form-group"><div class="input-group"><span class="input-group-addon"><i class="fa fa-search"></i></span><input type="text" name="q" id="q" class="form-control" placeholder="Search" /></div></div></form><a class="mo-nav-link" href="/projecthub/projects/new"><i class="fa fa-plus"></i><span>Add project</span></a><a class="mo-nav-link" href="/projecthub/users/sign_up?source=nav">Sign up / Login</a></div><script type="text/javascript">
|
|
$(function(){
|
|
$.ajax({
|
|
url: 'https://arduino-api.hackster.io/private/stats',
|
|
data: {
|
|
referrer: (document.referrer || document.origin),
|
|
|
|
id: '18672',
|
|
type: 'BaseArticle',
|
|
|
|
a: 'show',
|
|
c: 'projects'
|
|
},
|
|
xhrFields: {
|
|
withCredentials: true
|
|
},
|
|
method: 'POST'
|
|
});
|
|
});
|
|
</script><script>$(function(){
|
|
var s = "<span class='stat-figure'>3,632</span> views";
|
|
$('.impression-stats').html(s);
|
|
s = "<span class='stat-figure'>0</span> comments";
|
|
$('.comment-stats').html(s);
|
|
s = "<span class='stat-figure'>3</span> respects";
|
|
$('.respect-stats').html(s);
|
|
});</script><div data-react-class="FeedbackForm" data-react-props="{"project":{"id":18672},"openEvent":"open:feedbackForm","siteName":"Arduino Project Hub"}"></div><script>Utils.clearApiTokens();
|
|
var arduinoAuthenticated = Cookies.get("arduino_authenticated");
|
|
if (arduinoAuthenticated == "true") {
|
|
window.location.href = "https://www.hackster.io/users/auth/arduino?current_site=arduino&setup=true&redirect_to=%2Fprojecthub%2Fhs_education_georgia%2Ffade-led-without-using-pwm-08a82f";
|
|
}</script><script src="/assets/whitelabel/arduino/application-c6236db5026ade4fa3e9115226dc041338e68142149913749589b16f5868c2c4.js"></script><script src="//cdn.arduino.cc/header-footer/loader.js" type="text/javascript"></script> <script> ArduinoHeaderAndFooter({parts: ['create-nav'], auth: 'noauth'}).then(function () { var authDiv = $('#user-signin-signout'); var text = $(authDiv).text(); $(authDiv).find('button').replaceWith('<div class="button mobile-auth-button"><p>'+text+'</p></div>'); $('.grid-nav').append(authDiv); if ($('body').attr('data-user-signed-in')) { var uid = $('body').attr('data-user-name'); $('#add_project span.text').text('new project'); $('#add_project').attr('id', 'new_project'); $('#my_dashboard').attr('href', '/projecthub/' + uid); $('#my_dashboard').removeClass('logged-out'); } $( window ).scroll(function() { if ($(document).scrollTop() > 5) { $('.arduino-bbq').addClass('collapsed'); $('body').addClass('collapsed-nav'); } else { $('.arduino-bbq').removeClass('collapsed'); $('body').removeClass('collapsed-nav'); } }); $('.grid-nav #projecthub').on('click', function(event){ event.preventDefault(); $('#ino-create-nav .menu-toggle').click();}); if (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream) { $('body').addClass('ios'); } var url = window.location.href; var queryString = url.split('search?q=')[1]; if (queryString) { var searchBarValue = queryString.split('+').join(' '); $('input#q').val(searchBarValue); } $('.mobile-only').hide(); }); </script><form id="sign-out-form" class="hidden" method="post" action="/projecthub/users/sign_out"><input type="hidden" name="_method" value="delete" /><input type="submit" value="Sign out" /><input type="hidden" name="authenticity_token" value="LphsxFW+2IvYcg7AdrgiJHW0YzEeIflqzn8ILUw70Ep2fdpvWgxDKgsmahSXbReDvx3itVV/3oM2KVlBqytHJg==" /></form></body></html>
|