WIRELESS_InPixio.png

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

WIRELESS_InPixio.png
m_network.png
m_battery.png

2 Network    Module

2 Battery      Module

m_button.png
m_mc.png

 Button Module

    Motor Controller

  Module

m_motor.png

  Motor

Module

WIRELESS_InPixio.png

Click Here to download MODI Studio and follow the installation guide

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

WIRELESS_InPixio.png

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"

WIRELESS_InPixio.png

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

WIRELESS_InPixio.png

Let's write the program

WIRELESS_InPixio.png

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

ezgif.com-video-to-gif.gif

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

WIRELESS.jpg
WIRELESS.jpg

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

giphy.gif

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

WIRELESS.jpg

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

giphy (1).gif
WIRELESS.jpg

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"

giphy.gif

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

WIRELESS.jpg

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

giphy.gif
WIRELESS.jpg

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

WIRELESS.jpg