Book Image

Internet of Things Programming with JavaScript

Book Image

Internet of Things Programming with JavaScript

Overview of this book

The Internet of Things is taking the tech world by storm, and JavaScript is at its helm. This book will get you to grips with this exciting new technology. Where do Node.js, HTML5 and Windows 10 IoT Core come in with JavaScript and IoT? Why Raspberry Pi Zero rather than Arduino? How do you configure and build an IoT network from scratch? All your IoT JavaScript questions are answered in this book.
Table of Contents (15 chapters)
Internet of Things Programming with JavaScript
Credits
About the Author
www.packtpub.com
Customer Feedback
Preface

Regulating the current of an AC lamp dimmer


In this section, we will see how to regulate an AC lamp. For so many years I've wanted to explain and share a project like this, and I'm finally. This can be applied to regulate your lamps at home in order to decrease domestic power the consumption: the following sections will explain the project in more detail.

Hardware requirements

We need the following electronic components:

  • H-bridge

  • 24 AC transformer

  • Two resistors 22k (1 watt)

  • One integrated circuit (4N25)

  • One resistor 10k

  • One potentiometer of 5k

  • One resistor 330 ohms

  • One resistor 180 ohms

  • One integrated circuit MOC3011

  • One TRIAC 2N6073

In the following circuit diagram, we can see the connections for the dimmer from the Arduino board:

Software code

You can now either copy the code inside a file called Dimner.ino, or just get the complete code from the folder for this project:

int load = 10;  
int intensity = 128; 
 
void setup() 
{ 
pinMode(loaf, OUTPUT); 
attachInterrupt(0, cross_zero_int...