Control the Brightness of a Pin 13 LED with evive’s Potentiometer

evive Poentiometers
Description
Learn how to use an evive potentiometer to control the brightness of a pin 13 LED in Stage mode and Upload mode.

Introduction

A potentiometer is nothing but a variable resistor, i.e. we can easily vary/change the value of the resistor by moving or turning the slider or the knob respectively. Since the movement of the slider or the knob is smooth and continuous, the change in the value of the resistance is smooth.

evive has two inbuilt 10kΩ knob potentiometers connected to Arduino Mega pins A9 and A10, respectively.

evive PoentiometersWith the help of the potentiometers, you can control the speed of a DC motor as well as the angle of a servo motor through evive’s firmware. You can also control the amplitude and frequency of a signal in a function generator.

How to read evive’s potentiometer in Scratch

You can read evive’s potentiometer in PictoBlox with the help of a block in the evive palette known as the potentiometer () reading block.

potentiometer reading

Activity: Controlling the Brightness of pin 13 LED

Scratch 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. Then, drag and drop the set pwm pin () output as () block below the set () to () block. Inside this block, drag and drop the ()/() (division operator) block from the Operators palette.
  9. Inside the first space of the ()/() block, drag and drop the Brightness variable block; in the second space, drag write 4.Controlling evive's Potentiometer_Stage

Below is the complete script:

Controlling evive's Potentiometer_Stage

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 Potentiometer_Upload

Conclusion

In this lesson, you learned how to read evive’s potentiometer in Scratch mode and Upload mode. You also learned how to control the brightness of a pin 13 LED using the potentiometer. By combining this knowledge with other blocks, you can create interesting projects that involve the use of potentiometers.

Table of Contents