How to Control Brightness of an LED Using PWM in PictoBlox

evive Analog Write
About This Tutorial
This tutorial discusses PWM, scaling process, and how to control the brightness of evive’s pin 13 LED in Stage mode.
Tutorial Info

Components Required

ImageComponentQuantityAvailable in Kit
evive1
USB A-B Cable1

Introduction

PWM or Pulse Width Modulation is a technique for getting an analog output using digital signals. A digital signal, in general, can have either of the two values: HIGH/ON or LOW/OFF. If we switch the signal between these two values at an extremely fast rate, say, 500 times in 1 second, the signal at the output will appear to be continuous; it will seem as if it is an analog signal.

evive generates analog output in PWM form. It has 12 PWM pins for the same; they are numbered 2 – 13. Pin 13 is internally connected to the pin 13 LED.

set PWM pin () output as () Block

set PWM pin () output as () block set PWM output on evive PWM pins. The user can select the output from a range of 0 to 255. 

set pwm pin output as

Scaling

Scaling is the process of mapping a range of analog values to their corresponding digital values. The PWM output block in PictoBlox has numbers such as 0, 50, and 255 as options as output for the PWM pins. These numbers are the digital counterparts of their analog values, where 0 is 0V, and 255 is 5V.

Activity: Controlling Brightness of pin 13 LED Using PWM

 
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 in the scripting area.
  5. Next, go to the Control palette and drag and drop the forever block below the when flag clicked block.
  6. Go to the evive palette and drag and drop the set pwm pin () output as () block inside the forever block; the default pin number is 13.
  7. Now, go to the Variables palette and create a variable named Brightness. Once you create it, you’ll also see it in the top left corner of the stage. Right click on the variable in the stage. From the drop-down menu, select slider. In doing this you’ll see a slider, i.e. a line and a small rectangle that you can slide on that line. You can control the brightness of the LED with it.Slider Variable
  8. After creating the variable, drag and drop the Brightness variable block inside the space next to the word ‘as’ in the set pwm pin () output as () block.Variable Drag and Drop

Below is the complete script:

Controlling LED Brightness-Stage Mode-PWM_1

Click on the green flag to run the script, and then slide the ball on the slider to change the brightness of the LED.

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

Conclusion

It this tutorial, you learned how to control the brightness of an LED using PWM in PictoBlox.

Hope you had fun! 🙂

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
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
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
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
×

Cart