<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tutorials &#8211; Allen Productions</title>
	<atom:link href="https://www.allen.dj/category/tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.allen.dj</link>
	<description>Lighting, Lasers, Special FX, Automation, Custom Programming, Electrical Engineering</description>
	<lastBuildDate>Sat, 29 Aug 2020 07:08:00 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>
	<item>
		<title>The Best LED Strips</title>
		<link>https://www.allen.dj/best-led-strips/</link>
		
		<dc:creator><![CDATA[Allen Productions]]></dc:creator>
		<pubDate>Sat, 29 Aug 2020 06:50:56 +0000</pubDate>
				<category><![CDATA[Tutorials]]></category>
		<guid isPermaLink="false">https://www.allen.dj/?p=7303</guid>

					<description><![CDATA[People ask us all the time what are the best led strips on the market? Or what led strip products are available? The led strip market began with single color led strips such as cool white and warm white as the only available options. Some variants that were most commonly available were IP20, followed by [...]]]></description>
										<content:encoded><![CDATA[<p>People ask us all the time what are the <strong>best led strips on the market</strong>? Or what led strip products are available?</p>
<p><a href="https://www.allen.dj/wp-content/uploads/2013/09/IMG_0627-scaled.jpg"><img decoding="async" class="alignnone wp-image-1082 size-thumbnail" src="https://www.allen.dj/wp-content/uploads/2013/09/IMG_0627-125x125.jpg" alt="" width="125" height="125" srcset="https://www.allen.dj/wp-content/uploads/2013/09/IMG_0627-125x125.jpg 125w, https://www.allen.dj/wp-content/uploads/2013/09/IMG_0627-scaled-100x100.jpg 100w, https://www.allen.dj/wp-content/uploads/2013/09/IMG_0627-500x500.jpg 500w" sizes="(max-width: 125px) 100vw, 125px" /></a> <a href="https://www.allen.dj/wp-content/uploads/2013/09/IMG_0626-scaled.jpg"><img decoding="async" class="alignnone wp-image-1081 size-thumbnail" src="https://www.allen.dj/wp-content/uploads/2013/09/IMG_0626-125x125.jpg" alt="" width="125" height="125" srcset="https://www.allen.dj/wp-content/uploads/2013/09/IMG_0626-125x125.jpg 125w, https://www.allen.dj/wp-content/uploads/2013/09/IMG_0626-scaled-100x100.jpg 100w" sizes="(max-width: 125px) 100vw, 125px" /></a> <a href="https://www.allen.dj/wp-content/uploads/2013/09/IMG_0630-scaled.jpg"><img decoding="async" class="alignnone wp-image-1085 size-thumbnail" src="https://www.allen.dj/wp-content/uploads/2013/09/IMG_0630-125x125.jpg" alt="" width="125" height="125" srcset="https://www.allen.dj/wp-content/uploads/2013/09/IMG_0630-125x125.jpg 125w, https://www.allen.dj/wp-content/uploads/2013/09/IMG_0630-scaled-100x100.jpg 100w" sizes="(max-width: 125px) 100vw, 125px" /></a> <a href="https://www.allen.dj/wp-content/uploads/2013/09/IMG_0628-scaled.jpg"><img loading="lazy" decoding="async" class="alignnone wp-image-1083 size-thumbnail" src="https://www.allen.dj/wp-content/uploads/2013/09/IMG_0628-125x125.jpg" alt="" width="125" height="125" srcset="https://www.allen.dj/wp-content/uploads/2013/09/IMG_0628-125x125.jpg 125w, https://www.allen.dj/wp-content/uploads/2013/09/IMG_0628-scaled-100x100.jpg 100w" sizes="auto, (max-width: 125px) 100vw, 125px" /></a><a href="https://www.allen.dj/wp-content/uploads/2013/09/IMG_0624-scaled.jpg"> <img loading="lazy" decoding="async" class="alignnone wp-image-1079 size-thumbnail" src="https://www.allen.dj/wp-content/uploads/2013/09/IMG_0624-125x125.jpg" alt="" width="125" height="125" srcset="https://www.allen.dj/wp-content/uploads/2013/09/IMG_0624-125x125.jpg 125w, https://www.allen.dj/wp-content/uploads/2013/09/IMG_0624-scaled-100x100.jpg 100w, https://www.allen.dj/wp-content/uploads/2013/09/IMG_0624-500x500.jpg 500w" sizes="auto, (max-width: 125px) 100vw, 125px" /></a><a href="https://www.allen.dj/wp-content/uploads/2013/09/IMG_0629-scaled.jpg"> <img loading="lazy" decoding="async" class="alignnone wp-image-1084 size-thumbnail" src="https://www.allen.dj/wp-content/uploads/2013/09/IMG_0629-125x125.jpg" alt="" width="125" height="125" srcset="https://www.allen.dj/wp-content/uploads/2013/09/IMG_0629-125x125.jpg 125w, https://www.allen.dj/wp-content/uploads/2013/09/IMG_0629-scaled-100x100.jpg 100w" sizes="auto, (max-width: 125px) 100vw, 125px" /></a></p>
<p>The <strong>led strip</strong> market began with <strong>single color led strips</strong> such as <strong>cool white</strong> and <strong>warm white</strong> as the only available options. Some variants that were most commonly available were <strong>IP20</strong>, followed by <strong>IP65</strong>, then <strong>IP68</strong>, which is the <strong>ingress protection rating</strong> given to a product for resistance to water splashing onto it and submersion. Some products were in a flexible silicon-like or resin based shielding and some were found to be in a rigid aluminum channel of different sorts.</p>
<p>Over time as technological advancements made it possible, <strong>RGB Led Strips</strong> came into the market typically available in 12VDC and 24VDC versions.</p>
<p>One of the early pioneers of the LED Strip market in the USA were Elemental LED, previously know as Diode LED. Allen Productions had a vision for creating high brightness and high quality LED strips for endless applications in use for their own high profile clientele&#8217;s projects, when the competition&#8217;s and asian duplicating counterparts alike couldn&#8217;t produce the quality required.</p>
<p>And so, Allen Productions began making very high quality LED strips following as early pioneers of the LED Strip lighting industry, Advanced LED Controls Industry and 3D volumetric displays. Our products are not heavily marketed, they speak for themselves.</p>
<p>You may have not heard of AP, this was because many contractors kept them in the dark, taking all the credit for projects all while using their products and expertise for some of the most high profile projects around the world.</p>
<h2>Best Cool White LED Strips</h2>
<p>Here are some of the best cool white led strips you can find on the market.</p>
<h2>Best Warm White LED Strips</h2>
<p>Here are some of the best warm white led strips you can find on the market.</p>
<h2>Best RGB LED Strips</h2>
<p>Here are some of the best rgb led strips you can find on the market.</p>
<h2>Best RGBW LED Strips</h2>
<p>Here are some of the best rgbw led strips you can find on the market.</p>
<h2>Best Digital RGB LED Strips</h2>
<p>Here are some of the best digital rgb led strips you can find on the market.</p>
<h2>Best Digital RGBW LED Strips</h2>
<p>Here are some of the best digital rgbw led strips you can find on the market.</p>
<h3>Which type strip light LED chip is the best to purchase?</h3>
<p>This brings us to the next question. There are many chip sizes within led strip products to choose from: 2835, 3528 and 5050 are the 3 most used LED chips used. 2835 &#8211; is much smaller than 3528 and 5050 chips. Smaller chip sizes are typically used in special applications where small strip sizes are required. Allen Productions Only manufactures 5050 chip sized LED Strips, available only in 60/meter application since most of the projects we cater to are in the large commercial space.</p>
<p>Some say the chip size is not proportional to output or performance, we beg to differ, as engineers we know that something with a larger surface area can dissipate heat much better and faster, in turn having more performance in terms of longevity.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Boeing Automated Honeycomb Repair System &#124; Cal State Los Angeles</title>
		<link>https://www.allen.dj/boeing-automated-honeycomb-repair-system/</link>
		
		<dc:creator><![CDATA[Allen Productions]]></dc:creator>
		<pubDate>Tue, 27 Aug 2019 18:05:03 +0000</pubDate>
				<category><![CDATA[Electronics Projects]]></category>
		<category><![CDATA[Tutorials]]></category>
		<guid isPermaLink="false">https://www.allen.dj/?p=3072</guid>

					<description><![CDATA[The requirements for an Automated Honeycomb Repair System was set forth by Boeing&#8217;s Defense, Space and Security division, where honeycomb panels are heavily used on satellite structures in space, government, and military communication applications. This was a joint senior project by students at Cal State Los Angeles and The Boeing Company. The requirements were to design an [...]]]></description>
										<content:encoded><![CDATA[<p><a href="https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_1_Machine.jpg"><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-4925" src="https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_1_Machine-300x225.jpg" alt="" width="300" height="225" srcset="https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_1_Machine-300x225.jpg 300w, https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_1_Machine-510x383.jpg 510w, https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_1_Machine-768x576.jpg 768w, https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_1_Machine.jpg 960w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a><br />
<a href="https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_2_Group.jpg"><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-4926" src="https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_2_Group-300x164.jpg" alt="" width="300" height="164" srcset="https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_2_Group-300x164.jpg 300w, https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_2_Group-510x279.jpg 510w, https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_2_Group-1024x560.jpg 1024w, https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_2_Group-768x420.jpg 768w, https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_2_Group.jpg 1280w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a><br />
The requirements for an <strong>Automated Honeycomb Repair System</strong> was set forth by Boeing&#8217;s Defense, Space and Security division, where honeycomb panels are heavily used on satellite structures in space, government, and military communication applications. This was a joint senior project by students at Cal State Los Angeles and The Boeing Company.</p>
<p>The requirements were to design an automated repair system which would repair dents and damages on honeycomb panels in an automated fashion such that it would speed up the current &#8220;manual repair&#8221; of honeycomb panels which currently take an approximated <strong>3-4 hours</strong> to repair a single dent.</p>
<p>The basic concept of the process is to drill out the top face-sheet of the honeycomb with a 1/4&#8243; drill, core pick an inner diameter of 1&#8243; under the drilled top face-sheet to the bottom face-sheet, vacuum debris, and finally foam fill the core-picked void / affected area.</p>
<p>To achieve the aforementioned process, the mechanical sub-system consists of a ball-screw driven Y and Z axis and a rotary A axis for performing a tool change turret style and which also makes angled entry of a custom core-picker tool possible, which was also custom designed by our team for the actual core-picking task.</p>
<p><a href="https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_3_Machine.jpg"><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-4927" src="https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_3_Machine-300x225.jpg" alt="" width="300" height="225" srcset="https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_3_Machine-300x225.jpg 300w, https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_3_Machine-510x383.jpg 510w, https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_3_Machine-1024x768.jpg 1024w, https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_3_Machine-768x576.jpg 768w, https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_3_Machine.jpg 1280w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p><a href="https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_4.jpg"><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-4928" src="https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_4-300x199.jpg" alt="" width="300" height="199" srcset="https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_4-300x199.jpg 300w, https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_4-510x339.jpg 510w, https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_4-768x510.jpg 768w, https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_4.jpg 824w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p><a href="https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_5.jpg"><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-4929" src="https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_5-300x220.jpg" alt="" width="300" height="220" srcset="https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_5-300x220.jpg 300w, https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_5-510x374.jpg 510w, https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_5.jpg 706w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p><a href="https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_6.jpg"><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-4930" src="https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_6-300x197.jpg" alt="" width="300" height="197" srcset="https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_6-300x197.jpg 300w, https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_6-510x335.jpg 510w, https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_6-768x505.jpg 768w, https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_6.jpg 823w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p><a href="https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_7.jpg"><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-4931" src="https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_7-300x196.jpg" alt="" width="300" height="196" srcset="https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_7-300x196.jpg 300w, https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_7-510x333.jpg 510w, https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_7.jpg 730w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>The electrical sub-system consists of a <strong>single</strong> Arduino Due for complete machine control and automation driving: 3 Stepper Motors &amp; Drives, a Servo Motor + Drive, 6 Solenoid Valves, Full 20&#215;4 LCD Display for Status updates throughout the process, Full Color RGBW LED Strip for visual status feedback, 8 Relays, also Input devices include: 4 optical homing sensors, one for each axis, tool touch plate input, probe input, and finally start + stop inputs.</p>
<p><a href="https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_8.jpg"><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-4932" src="https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_8-300x201.jpg" alt="" width="300" height="201" srcset="https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_8-300x201.jpg 300w, https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_8-510x342.jpg 510w, https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_8-768x515.jpg 768w, https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_8.jpg 797w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p><a href="https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_9_Controls.jpg"><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-4938" src="https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_9_Controls-300x198.jpg" alt="" width="300" height="198" srcset="https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_9_Controls-300x198.jpg 300w, https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_9_Controls-510x337.jpg 510w, https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_9_Controls-768x507.jpg 768w, https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_9_Controls.jpg 819w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>All possible noise generating devices such as power supplies and motor drives were placed far away from logic level devices such as the control microprocessor / Arduino. This was initially designed with that in mind as can be seen in the Solid-works model layout.</p>
<p><a href="https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_10.jpg"><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-4939" src="https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_10-300x117.jpg" alt="" width="300" height="117" srcset="https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_10-300x117.jpg 300w, https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_10-510x198.jpg 510w, https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_10-1024x398.jpg 1024w, https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_10-768x299.jpg 768w, https://www.allen.dj/wp-content/uploads/2019/08/Honeycomb_10.jpg 1280w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>From Solid-works model on the left to realization on the right, the figure above shows the actual machine after fabrication. The entire machine automation process brought down the manual repair time of 4-6 hours to roughly 10 minutes.</p>
<p>Below is a time-lapse of the entire process of the Automated Repair Machine Process.</p>
<p><iframe loading="lazy" src="https://www.youtube.com/embed/q-pWUgsOAQo" width="744" height="419" frameborder="0" allowfullscreen="allowfullscreen"></iframe></p>
<p>The video begins with all the user-replaceable tools being &#8220;tool-touched&#8221; or measured for any change due to wear or replacement, as they will not be exactly placed into location via human hands, this applies to the drill bit, probe, and custom core-picking tool. Next the face of the honeycomb panel is measured via a probe, and drilling of the face sheet is performed. After drilling, the bottom face-sheet is measured to make sure the next process of core picking does not puncture the bottom face sheet when clearing the inner honeycomb core. Using those measured distances from top to bottom face-sheet, the core picking process is performed, pay attention to the fine motor movements required for the custom angled tool to make entry and exit the previously drilled hole. Next the vacuum clears all the debris in the core picked void space, and finally foam is filled into the affected area, completing the repair process, the machine waits for another dent and start button press to begin its process again.</p>
<p><strong>Senior Team Members:</strong> Allen Analian (EE), Jeffrey T. Iwasaki (ME), Jonathan Sanabria (ME), Gino Kiettisak (ME), Carlos A. Sanchez (ME), Alberto M. Cortes (EE)</p>
<p><strong>Acknowledgments:</strong> Special Thanks to the Boeing Company &amp; Cal State Los Angeles for the opportunity, Theodore (Ted) Nye (Senior Design Director), Teofilo El-Masri, Cameron Massey, Jose Armenta, Jonathan Fish (Boeing Liaisons).</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>ESP8266 NodeMCU &#8211; Toggle Button &#038; Slider &#8211; Remote Node.js Server Example</title>
		<link>https://www.allen.dj/esp8266-nodemcu-button-slider-remote-node-js-server/</link>
		
		<dc:creator><![CDATA[Allen Productions]]></dc:creator>
		<pubDate>Fri, 16 Nov 2018 21:59:43 +0000</pubDate>
				<category><![CDATA[Electronics Projects]]></category>
		<category><![CDATA[Tutorials]]></category>
		<guid isPermaLink="false">https://www.allen.dj/?p=1478</guid>

					<description><![CDATA[After looking all over for bits and pieces of how to properly get a Remote Node.js Server to communicate with a ESP8266 or ESP32 NodeMCU, I was finally able to get everything working properly. With so many libraries of the same variant of implementing a Socket.io client on a NodeMCU, it was very confusing when [...]]]></description>
										<content:encoded><![CDATA[<p>After looking all over for bits and pieces of how to properly get a Remote Node.js Server to communicate with a ESP8266 or ESP32 NodeMCU, I was finally able to get everything working properly. With so many libraries of the same variant of implementing a Socket.io client on a NodeMCU, it was very confusing when functions had the same or very similar names and arguments.</p>
<p>I wanted a way to remotely control a device with a button toggle switch (LED, Mosfet, Relay etc) and a range slider to control brightness of an LED, Triac etc with a web based interface on a NodeMCU, communicating to a centralized web server.</p>
<p>Here is an example of how I was able to achieve it with fairly great results. Hopefully this helps others in trying to achieve the same results. For more buttons and sliders their values can be stored in 2 arrays one for switch state values and another for dimmer pwm values, both with a corresponding id to each button or slider.</p>
<p>Below is the <strong>Server.js</strong> file running on the remote <strong>Node.js Web Server</strong> :</p>
<pre class="brush: jscript; title: ; notranslate">

var http = require('http');

var express = require('express');

var path = require('path');

var app = express();

// all environments
app.set('port', process.env.PORT || 3000);

app.get('/', function (req, res) {

res.sendFile(__dirname + '/index.html');

});
app.use(express.static(__dirname + '/'));

var server = http.createServer(app);

var io = require('socket.io').listen(server);

server.listen(app.get('port'), function(){
console.log('Express server listening on port ' + app.get('port'));
});

// Define/initialize our global vars
var socketCount = 0

var brightness = 0; //static variable to hold the current brightness
var swstate = 0;

io.sockets.on('connection', function(socket){
//console.log(socket.id);
// Socket has connected, increase socket count
socketCount++
// Let all sockets know how many are connected
io.sockets.emit('users connected', socketCount)

socket.emit('swstate', swstate);

socket.on('swstate',function(){
swstate = 1 - swstate;
//console.log(swstate);
io.emit('swstate', swstate);
});

socket.emit('led', {value: brightness}); //send the new client the current brightness

socket.on('led', function (data) { //makes the socket react to 'led' packets by calling this function
brightness = data.value; //updates brightness from the data object
io.sockets.emit('led', {value: brightness}); //sends the updated brightness to all connected clients
});

});

process.on('SIGINT', function() {
//Do things on Script Termination...
console.log('\n Bye!')
process.exit();
});

</pre>
<p>Start the <strong>node.js server script</strong> on the remote server using the command in SSH:<br />
forever start -o out.log -e err.log Server.js</p>
<p>Below is the <strong>index.html</strong> file running in the same directory as the <strong>Node.js Script</strong> (This page is served by the Node.js http Server) :</p>
<pre class="brush: xml; title: ; notranslate">
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Node.js Socket.io Testing&lt;/title&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css&quot;&gt;
&lt;link href=&quot;https://gitcdn.github.io/bootstrap-toggle/2.2.2/css/bootstrap-toggle.min.css&quot; rel=&quot;stylesheet&quot;&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdnjs.cloudflare.com/ajax/libs/bootstrap-switch/3.3.2/css/bootstrap2/bootstrap-switch.min.css&quot;&gt;
&lt;img src=&quot;data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7&quot; data-wp-preserve=&quot;%3Cscript%20src%3D%22http%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fjquery%2F1.11.3%2Fjquery.min.js%22%3E%3C%2Fscript%3E&quot; data-mce-resize=&quot;false&quot; data-mce-placeholder=&quot;1&quot; class=&quot;mce-object&quot; width=&quot;20&quot; height=&quot;20&quot; alt=&quot;&lt;script&gt;&quot; title=&quot;&lt;script&gt;&quot; /&gt;
&lt;img src=&quot;data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7&quot; data-wp-preserve=&quot;%3Cscript%20src%3D%22https%3A%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Frangeslider.js%2F2.3.2%2Frangeslider.min.css%22%3E%3C%2Fscript%3E&quot; data-mce-resize=&quot;false&quot; data-mce-placeholder=&quot;1&quot; class=&quot;mce-object&quot; width=&quot;20&quot; height=&quot;20&quot; alt=&quot;&lt;script&gt;&quot; title=&quot;&lt;script&gt;&quot; /&gt;
&lt;!--&#x5B;if IE]&gt;
&lt;img src=&quot;data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7&quot; data-wp-preserve=&quot;%3Cscript%20src%3D%22https%3A%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Fjson3%2F3.3.2%2Fjson3.min.js%22%3E%0A%3Cscript%20src%3D%22https%3A%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Fsocket.io%2F2.1.1%2Fsocket.io.dev.js%22%3E%3C%2Fscript%3E&quot; data-mce-resize=&quot;false&quot; data-mce-placeholder=&quot;1&quot; class=&quot;mce-object&quot; width=&quot;20&quot; height=&quot;20&quot; alt=&quot;&lt;script&gt;&quot; title=&quot;&lt;script&gt;&quot; /&gt;
&lt;!&#x5B;endif]--&gt;
&lt;!--&#x5B;if !IE]&gt;&lt;!--&gt;
&lt;!--&lt;!&#x5B;endif]--&gt;
&lt;img src=&quot;data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7&quot; data-wp-preserve=&quot;%3Cscript%20src%3D%22%2Fsocket.io%2Fsocket.io.js%22%3E%3C%2Fscript%3E&quot; data-mce-resize=&quot;false&quot; data-mce-placeholder=&quot;1&quot; class=&quot;mce-object&quot; width=&quot;20&quot; height=&quot;20&quot; alt=&quot;&lt;script&gt;&quot; title=&quot;&lt;script&gt;&quot; /&gt;
&lt;img src=&quot;data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7&quot; data-wp-preserve=&quot;%3Cscript%20src%3D%22https%3A%2F%2Fmaxcdn.bootstrapcdn.com%2Fbootstrap%2F3.3.5%2Fjs%2Fbootstrap.min.js%22%3E%3C%2Fscript%3E&quot; data-mce-resize=&quot;false&quot; data-mce-placeholder=&quot;1&quot; class=&quot;mce-object&quot; width=&quot;20&quot; height=&quot;20&quot; alt=&quot;&lt;script&gt;&quot; title=&quot;&lt;script&gt;&quot; /&gt;
&lt;img src=&quot;data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7&quot; data-wp-preserve=&quot;%3Cscript%20src%3D%22https%3A%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Fbootstrap-switch%2F3.3.2%2Fjs%2Fbootstrap-switch.min.js%22%3E%3C%2Fscript%3E&quot; data-mce-resize=&quot;false&quot; data-mce-placeholder=&quot;1&quot; class=&quot;mce-object&quot; width=&quot;20&quot; height=&quot;20&quot; alt=&quot;&lt;script&gt;&quot; title=&quot;&lt;script&gt;&quot; /&gt;
&lt;img src=&quot;data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7&quot; data-wp-preserve=&quot;%3Cscript%20src%3D%22https%3A%2F%2Fgitcdn.github.io%2Fbootstrap-toggle%2F2.2.2%2Fjs%2Fbootstrap-toggle.min.js%22%3E%3C%2Fscript%3E&quot; data-mce-resize=&quot;false&quot; data-mce-placeholder=&quot;1&quot; class=&quot;mce-object&quot; width=&quot;20&quot; height=&quot;20&quot; alt=&quot;&lt;script&gt;&quot; title=&quot;&lt;script&gt;&quot; /&gt;
&lt;img src=&quot;data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7&quot; data-wp-preserve=&quot;%3Cscript%20src%3D%22https%3A%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Frangeslider.js%2F2.3.2%2Frangeslider.min.js%22%3E%3C%2Fscript%3E&quot; data-mce-resize=&quot;false&quot; data-mce-placeholder=&quot;1&quot; class=&quot;mce-object&quot; width=&quot;20&quot; height=&quot;20&quot; alt=&quot;&lt;script&gt;&quot; title=&quot;&lt;script&gt;&quot; /&gt;
 
&lt;img src=&quot;data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7&quot; data-wp-preserve=&quot;%3Cstyle%3E%0Abody%20%7B%0Amargin-top%3A%2020px%3B%0Amargin-left%3A%2030px%3B%0A%7D%0A%0Ainput%5Btype%3Drange%5D%7B%0A-webkit-appearance%3A%20none%3B%0Awidth%3A%2080%25%3B%0A%7D%0A%0Ainput%5Btype%3Drange%5D%3A%3A-webkit-slider-runnable-track%20%7B%0Aheight%3A%2010px%3B%0Abackground%3A%20%230c75b3%3B%0Aborder%3A%20none%3B%0Aborder-radius%3A%203px%3B%0A%7D%0A%0Ainput%5Btype%3Drange%5D%3A%3A-webkit-slider-thumb%20%7B%0A-webkit-appearance%3A%20none%3B%0Aborder%3A%20none%3B%0Aheight%3A%2032px%3B%0Awidth%3A%2032px%3B%0Aborder-radius%3A%2050%25%3B%0Abackground%3A%20%2314c0dc%3B%0Amargin-top%3A%20-12px%3B%0A%7D%0A%0Ainput%5Btype%3Drange%5D%3Afocus%20%7B%0Aoutline%3A%20none%3B%0A%7D%0A%0Ainput%5Btype%3Drange%5D%3Afocus%3A%3A-webkit-slider-runnable-track%20%7B%0Abackground%3A%20%230c75b3%3B%0A%7D%0A%3C%2Fstyle%3E&quot; data-mce-resize=&quot;false&quot; data-mce-placeholder=&quot;1&quot; class=&quot;mce-object&quot; width=&quot;20&quot; height=&quot;20&quot; alt=&quot;
&lt;style&gt;&quot; title=&quot;
&lt;style&gt;&quot; /&gt;

&lt;/head&gt;
&lt;body&gt;
 

&lt;div class=&quot;row&quot;&gt;
 

&lt;div class=&quot;alert alert-info col-md-3 col-md-3&quot; role=&quot;alert&quot; id=&quot;usersConnected&quot;&gt;&lt;/div&gt;

 
&lt;/div&gt;

 
&lt;strong&gt;Slider Value: &lt;/strong&gt;&lt;span id=&quot;outputText&quot;&gt;50&lt;/span&gt;
 
&lt;input type=&quot;range&quot; id= &quot;inputSlider&quot; min=&quot;0&quot; max=&quot;1023&quot; value=&quot;0&quot; step=&quot;1&quot; oninput=&quot;showValue(this.value)&quot; /&gt;
 
&lt;strong&gt;SW State: &lt;/strong&gt;&lt;span id=&quot;swval&quot;&gt;&lt;/span&gt;
 
&lt;input type=&quot;checkbox&quot; data-toggle=&quot;toggle&quot; data-on=&quot;Off&quot; data-off=&quot;On&quot; id=&quot;toggle&quot;&gt;
 
&lt;img src=&quot;data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7&quot; data-wp-preserve=&quot;%3Cscript%20type%3D%22text%2Fjavascript%22%3E%0A%0A%2F%2F%20Connect%20to%20our%20node%2Fwebsockets%20server%0Avar%20socket%20%3D%20io.connect('http%3A%2F%2Fwww.domain.com%3A3000')%3B%0A%0Avar%20websocket%20%3D%200%3B%0A%0A%24(%22%23toggle%22).change(function()%7B%0Aif(!websocket)%20%7B%0Aif(%24(%22%23toggle%22).prop(%22checked%22)%20%3D%3D%201)%7B%0Avar%20swstate%20%3D%201%3B%0Asocket.emit('swstate'%2C%20swstate)%3B%0A%7Delse%7B%0Avar%20swstate%20%3D%200%3B%0Asocket.emit('swstate'%2C%20swstate)%3B%0A%7D%0A%7D%20else%20%7Bwebsocket%20%3D%200%3B%7D%0A%7D)%3B%0A%0Asocket.on('swstate'%2C%20function(swstate)%20%7B%0AswValue(swstate)%3B%0Awebsocket%20%3D%201%3B%0Aif(swstate%20%3D%3D%3D%201)%7B%0A%24('%23toggle').bootstrapToggle('on')%3B%7D%0Aelse%7B%0A%24('%23toggle').bootstrapToggle('off')%3B%7D%0A%0A%7D)%3B%0A%2F%2F%20New%20socket%20connected%2C%20display%20new%20count%20on%20page%0Asocket.on('users%20connected'%2C%20function(data)%7B%0A%24('%23usersConnected').html('%3Cstrong%3EUsers%20Connected%3A%3C%2Fstrong%3E%20'%20%2B%20data)%0A%7D)%0A%0Asocket.on('led'%2C%20function%20(data)%20%7B%0Adocument.getElementById(%22inputSlider%22).value%20%3D%20data.value%3B%0Adocument.getElementById(%22outputText%22).innerHTML%20%3D%20data.value%3B%0A%7D)%3B%0A%0Afunction%20showValue(newValue)%0A%7B%0Adocument.getElementById(%22outputText%22).innerHTML%3DnewValue%3B%0Asocket.emit('led'%2C%20%7B%20value%3A%20newValue%20%7D)%3B%0A%7D%0Afunction%20swValue(swstate)%0A%7B%0Adocument.getElementById(%22swval%22).innerHTML%3Dswstate%3B%0A%7D%0A%2F%2F%7D)%0A%3C%2Fscript%3E&quot; data-mce-resize=&quot;false&quot; data-mce-placeholder=&quot;1&quot; class=&quot;mce-object&quot; width=&quot;20&quot; height=&quot;20&quot; alt=&quot;&lt;script&gt;&quot; title=&quot;&lt;script&gt;&quot; /&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Below is the Code for the <strong>ESP8266 NodeMCU</strong> programmed on the <strong>Arduino IDE</strong> (v1.8.5) environment:</p>
<pre class="brush: jscript; title: ; notranslate">
#include &lt;ESP8266WiFi.h&gt;          //ESP8266 Core WiFi Library (you most likely already have this in your sketch)

//#include &lt;DNSServer.h&gt; //Local DNS Server used for redirecting all requests to the configuration portal
#include &lt;ESP8266WebServer.h&gt; //Local WebServer used to serve the configuration portal
#include &lt;WiFiManager.h&gt; //https://github.com/tzapu/WiFiManager WiFi Configuration Magic
#include &lt;ESP8266mDNS.h&gt;
#include &lt;SocketIoClient.h&gt;
#include &lt;ArduinoJson.h&gt;

#define LED 13
// Pin D7 on NodeMCU
#define LEDPWM 12
// Pin D6 on NodeMCU

const char* mdnsName = &quot;esp8266&quot;;

// DNS server
const byte DNS_PORT = 53;
DNSServer dnsServer;

ESP8266WebServer webServer(80);

SocketIoClient socket;

void light(const char * payload, size_t length) {
String msg;
//String text = String((char *) &amp;payload&#x5B;0]);
msg = String((char*)payload);
if(msg==&quot;1&quot;){ digitalWrite(LED,HIGH); Serial.println(&quot;LED ON&quot;);}else{digitalWrite(LED,LOW); Serial.println(&quot;LED OFF&quot;);}
Serial.println(msg);
}

void lightpwm(const char * payload, size_t length) {

DynamicJsonBuffer jsonBuffer(JSON_OBJECT_SIZE(4) + 100);

//String text = String((char *) &amp;payload&#x5B;0]);
//String msg2 = String((char*)payload);

JsonObject&amp; root = jsonBuffer.parseObject(String((char*)payload));
int pwmval = root&#x5B;&quot;value&quot;];
//Serial.println(&quot;PWM LED&quot;);
analogWrite(LEDPWM, pwmval);
}

String responseHTML = &quot;&quot;
&quot;&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;head&gt;&lt;title&gt;Hello World!&lt;/title&gt;&lt;/head&gt;&lt;body&gt;&quot;
&quot;

&lt;h1&gt;Hello World!&lt;/h1&gt;


All requests are redirected here.

&lt;/body&gt;&lt;/html&gt;&quot;;

//flag for saving data
bool shouldSaveConfig = false;

void configModeCallback (WiFiManager *myWiFiManager) {
Serial.println(&quot;Entered config mode&quot;);
Serial.println(WiFi.softAPIP());
Serial.println(myWiFiManager-&gt;getConfigPortalSSID());
}

//callback notifying us of the need to save config
void saveConfigCallback () {
Serial.println(&quot;Should save config&quot;);
shouldSaveConfig = true;
}

void setup() {
// put your setup code here, to run once:
pinMode(LED, OUTPUT);
pinMode(LEDPWM, OUTPUT);
digitalWrite(LED, LOW);
Serial.begin(115200);
WiFiManager wifiManager;
//reset settings - for testing
//wifiManager.resetSettings();
wifiManager.setConfigPortalTimeout(360);
wifiManager.setDebugOutput(false);

wifiManager.setAPCallback(configModeCallback);
//WiFiManager.setHostname(mdnsName);
//fetches ssid and pass and tries to connect
//if it does not connect it starts an access point with the specified name
//here &quot;AutoConnectAP&quot;
//and goes into a blocking loop awaiting configuration
if(!wifiManager.autoConnect(&quot;Allen_LED&quot;, &quot;1234pass&quot;)) {
Serial.println(&quot;failed to connect and hit timeout&quot;);
//reset and try again, or maybe put it to deep sleep
ESP.reset();
delay(1000);
}
wifiManager.setSaveConfigCallback(saveConfigCallback);

//if you get here you have connected to the WiFi
Serial.println(&quot;Connected!... YES!&quot;);
Serial.println(&quot;Local IP is: &quot;);
Serial.println(WiFi.localIP());
WiFi.hostname(mdnsName);
if (!MDNS.begin(mdnsName, WiFi.localIP())) {
// Start the mDNS responder for esp8266.local
Serial.println(&quot;Error setting up MDNS responder!&quot;);
}
Serial.println(&quot;mDNS responder started&quot;);
// Add service to MDNS-SD
MDNS.addService(&quot;http&quot;, &quot;tcp&quot;, 80);
MDNS.addServiceTxt(&quot;http&quot;, &quot;tcp&quot;, &quot;url&quot;, &quot;http://esp8266.local&quot;);

socket.begin(&quot;www.domain.com&quot;, 3000, &quot;/socket.io/?transport=websocket&quot;);
//socket.on(&quot;event&quot;, event);
socket.on(&quot;swstate&quot;, light);
socket.on(&quot;led&quot;, lightpwm);

// HTTP Basic Authorization (optional)
//webSocket.setAuthorization(&quot;username&quot;, &quot;password&quot;);

//socket.emit(&quot;plainString&quot;, &quot;\&quot;this is a plain string\&quot;&quot;);
//socket.emit(&quot;swstate&quot;, &quot;1&quot;);

// replay to all requests with same HTML
webServer.onNotFound(&#x5B;]() {
webServer.send(200, &quot;text/html&quot;, responseHTML);
});
webServer.begin();
}

void loop() {
// put your main code here, to run repeatedly:
dnsServer.processNextRequest();
webServer.handleClient();
socket.loop();
}

</pre>
<p>The end result will look like the screenshot below where the Button Switch controls Pin D7 on the NodeMCU, and the Slider will create a PWM Dimmer on Pin D6, which you can connect an LED to see the brightness level correspond to the slider in just about real-time. One side note: Make sure you replace domain.com in all the code above to reflect where your node.js server is running, localhost, ip, domain, hostname etc. <a href="https://www.allen.dj/wp-content/uploads/2018/11/nodejs_tutorial.png"><img loading="lazy" decoding="async" class="alignnone wp-image-1490 size-full" src="https://www.allen.dj/wp-content/uploads/2018/11/nodejs_tutorial.png" alt="" width="829" height="341" srcset="https://www.allen.dj/wp-content/uploads/2018/11/nodejs_tutorial.png 829w, https://www.allen.dj/wp-content/uploads/2018/11/nodejs_tutorial-510x210.png 510w, https://www.allen.dj/wp-content/uploads/2018/11/nodejs_tutorial-300x123.png 300w, https://www.allen.dj/wp-content/uploads/2018/11/nodejs_tutorial-768x316.png 768w" sizes="auto, (max-width: 829px) 100vw, 829px" /></a></p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
