Let's start solving the problem by making a "Smart Switch using a wireless button".This kind of smart switch can be placed beside your bed to turn on/off the light. this wireless button will be connected to the motor that is placed to the actual light switch on the wall.

Let's express the flow of an algorithm

The light is turned off

Press the button module

The motor rotates to the "ON" direction of the light switch

Press the button module

The motor rotates to the "OFF" direction of the light switch

2 Network    Module

2 Battery      Module

 Button Module

    Motor Controller

  Module

  Motor

Module

Click Here to download MODI Studio and follow the installation guide

After installing the MODI Studio. we will create a new project

Name your own project depends on what you want or base on your project. as sample below we name this project "Smart_Switch" the click "Create"

Let's start by connecting modules to use MODI Studio by connecting a micro USB cable to the network module and the other end to the USB port of your computer

When the network module is connected to the computer with the MODI Studio. the MODI Studio will automatically detect the modules and will be seen on the module map

Let's write the program

Move the motor module from the module map to the code editor. you can do this by dragging the icon of the module to code editor

First, we need to set the default value of the motor angle to zero which is gonna be the "off" value of the Smart Switch

Add the "IF" block that can be found on the top left side of the MODI Studio to the code Editor and select button

 Under the "IF" option, set the button module as a toggle button for us to have a status of "ON" or "OFF".

Drag the motor module under the "IF" condition. Doing this will give the command to the motor to change it's angle to 30 when the status of the button is "TRUE" which will turn the Light Switch on

Adding the 2nd "IF" block will give you an option to choose what are you gonna use.in this case we will use the "Else IF"

On this "ELSE IF" we are gonna make the "FALSE" condtion on the toggle button to turn the lights off

The button condition is now "FALSE". Let's drag the motor module under the "Else IF" condition and put the motor angle to zero to create the the "OFF" status of the Light Switch

Click the "Upload" button on the top of the application and install the light swich

  • facebook
  • Twitter Clean
  • White Google+ Icon