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
evive1
USB A-B Cable1

Introduction

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.

Conclusion

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

Hope you had fun! 🙂

This helped
This didn't help
Share this Tutorial
Share on facebook
Facebook
Share on twitter
Twitter
Share on google
Google+
Share on pinterest
Pinterest
Share on reddit
Reddit
Share on print
Print
Related Projects & Tutorials
All articles loaded
No more articles to load
Featured Projects
Robotic-Arm-Bartender
DIY Robotic Arm Bartender

This project will show you how to make your own robotic arm bartender that will make you a star host!

All articles loaded
No more articles to load
Close Menu
×

Cart

No mo #FOMO on the coolest project-making app out there!

Check it out RIGHT NOW on Product Hunt!
Launch-Pop-Up
Dabble is trending on Product Hunt!
Check it out and let us know what your favorite feature is. 😉
x