How to Read evive’s Switches in PictoBlox

evive Tactile Switch Pushbuttons
About This Tutorial
This tutorial discusses what are switches, evive’s switches and how to read them in PictoBlox, and making a Torch using evive’s pin 13 LED, tactile switch, and potentiometer.
Tutorial Info

Components Required

ImageComponentQuantityAvailable in Kit
USB A-B Cable1


A switch is one of the most basic, but very important components in a circuit. When the switch is open, the circuit is broken, and no current will flow through it. When the switch is closed, the circuit is closed or made, and therefore, current will flow through it.

Switches can broadly be classified into two types:

  1. Mechanical Switches
  2. Electrical Switches

Mechanical switches can further be classified into two types:

  1. Maintained Switches: These switches stay in one state i.e. either ON or OFF, unless the state is changed by someone. E.g. slide switches. evive has two inbuilt 3-way slide switches. Slide switch 1 is connected to Arduino pins 40 and 41, both active high. This means that when the switch is slid up, pin 40 is high. When it slides down, pin 41 is high while both are low when the switch is in the middle. Slide switch 2 is connected to pins 42 and 43, and works in a similar manner as slide switch 1.evive Slide Switch
  2. Momentary switches: These switches stay in a state i.e. either ON or OFF, as long as they are activated. They come back to their original state once you release them. E.g. tactile switches. evive has two tactile switches connected to Arduino pins 38 and 39, both active high. This means that the pins are at +5V when you press the switch, and at 0V (Ground) otherwise.evive Tactile Switch Pushbuttons

How to Read evive’s Switches in PictoBlox

You can read evive’s switches in PictoBlox with the help of two blocks in the evive palette:

  1. tactile switch () pressed?tactile switch pressed
  2. slide switch () is in state () ?slide switch is in state

Activity: Making a Torch Using Pin 13 LED

Stage Mode

evive Notes Icon
When working with evive on PictoBlox for the very first time, or if you’ve previously uploaded another code to evive, you must upload the firmware in order to upload new code to it. You can find the procedure for the same HERE.

Follow the steps below to write the script:

  1. Connect evive to your computer and open PictoBlox; if already open and working on a project, save that project. Then, click on New.
  2. Go to the toolbar and click on the Board menu. Then select evive as your board. Pictoblox Board Selection
  3. Next, click on the Connect menu and from the fly-out menu, select the Port to which evive is connected e.g. COMXX or ttyXX.Once you select the port, the icon beside the Connect tab will become connected.Connect-Disconnect Icon
  4. Go to the Events palette and drag and drop the when flag clicked block.
  5. Next, go to the Control palette and drag and attach the forever block below the when flag clicked block.
  6. Then, go to the Variables palette and create a variable named Brightness and drag and drop the set () to () block inside the forever block; Brightness is set as default.
  7. Next, go to the evive palette and drag and drop the potentiometer () reading inside the space in the set () to () block; potentiometer 1 is set as default potentiometer.Controlling evive's Switches in PictoBlox_potentiometer_block
  8. From the Control palette, drag and drop the if-else block below the set () to () block. Inside the diamond-shaped space, drag and drop the tactile switch () pressed? block; tactile switch 1 is set as the default switch.
  9. Drag and drop the set pwm pin () output as () block below the if arm of the if-else block. Set the pin as 13 and drag and drop the ()/() (division operator) block from the Operators palette in the white space.
  10. Inside the first space of the ()/() block, drag and drop the Brightness variable block; in the second space, drag write 4.Divide Brightness by 4
  11. Below the else arm of the if-else block, drag and drop the set digital pin () output as () block; set the pin as 13 and the output as LOW.
  12. Finally, outside the if-else block, drag and drop a wait () secs block from the Control palette; write 0.1 in the space.

Below is the complete script:

Controlling evive's Switches in PictoBlox_Stage_1

Click on the green flag to run the script and rotate the potentiometer to change the brightness of the LED. 

Click on the red octagon, next to the green flag to stop the script.

Upload Mode

Below is the script in Upload mode. All you need to do is replace the when flag clicked block with the when evive starts up block.

Controlling evive's Switches in PictoBlox_Upload_1

evive Explore
You can modify the script by replacing the tactile switch () pressed? block with the slide switch () is in state ()? block.


It this tutorial, you learned how to control evive’s switches in both Stage mode and Upload mode.

Hope you had fun! 🙂

Share this Tutorial
Share on facebook
Share on twitter
Share on google
Share on pinterest
Share on reddit
Share on print
Related Projects & Tutorials
PictoBlox – Stage Mode
In this tutorial, you learned about PictoBlox's Stage mode and how to control hardware in real-time using a USB cable or over Bluetooth. 
PictoBlox – Upload Mode
In this tutorial, you'll see what is PictoBlox's Upload mode and how to use it to control our hardware wirelessly, i.e. without being connected to computer.
Interfacing Dabble with evive
In this tutorial, we learned how to control actuators or send commands to them wirelessly via a Smartphone using Dabble.
All articles loaded
No more articles to load
Featured Projects
All articles loaded
No more articles to load

Leave a Reply

Close Menu


Get an extra 10% OFF + FREE shipping worldwide on orders above $100.