Table of Contents

Interfacing Force Sensor with Quarky

Example Description
Learn about the significance of force sensors and their applications. Discover how to interface a force sensor with Quarky using Pictoblox.

Introduction

A force sensor, also known as a load cell or force transducer, is a device designed to measure the force or load applied to it. It’s used in various applications to quantify the magnitude of forces in different directions. Force sensors are utilized in fields such as engineering, manufacturing, robotics, healthcare, and more.

 

Circuit Diagram

 

Setting up the stage

  1. Go to Sprite button and add bell as a ew sprite.
  2. change the backdrop to  “Sky blue 2”.
  3. Now you have two sprites on the stage “Tobi ” and “Bell”.  change 
  4.  Select “Bell” and set its x value to 0 and y to 150. and size to 50% at the bottom of the stage.
  5. Change the size of Tobi to 80%
  6. Now the final thing adding the sound effect. go to sound block, search for bell, and add ‘Doorbll”.

Code

  1. Open Pictoblox and create a new file.
  2. Go to the board menu and select Quarky.
  3. Now after setting up the stage, select Tobi and start writing the below code for Tobi.
  4. From event palette,  drag ” when flag clicked” block into th scripting area.
  5.  Let’s set the initial location for Tobi in the stage as x=0, y=0. Goto Motion palette and add “goto x() y()” block, feed the value for x and y.
  6. Create a variable as “Initial value ” to store the initial (or normal) value of the sensor.
  7. From Variable palette, drag “Set () to ()” and add after the goto block. select “initial value from the drop-down button.
  8. From Sensor palette of Quarky. place ” read analog sensor () at ()” block in place of 0. and choose generic from the list.
  9. Now add a forever block in the script and put “if-then-else” block inside the forever block.
  10. From operator palette, add grater then operator in the conditional part and compare the current value of the sensor with initial value, as shown below.
  11.  Inside the if section of the block, we have to map the sensor value in such a way that whatever the value sensor is generating, it must get converted from 0-150, so that our Tobi can jump to ring the bell. For this, we are going to use  “change y by ()” block from motion palette and “map () from () ~() to () ~()” block from quarky palette.
  12. place the sensor value in place of 50 and set the required range. as shown below.
  13. With this our Tobi can jump account to the data fetched from the sensor. Since we are trying to ring the bell, so we have to set the condition for this. add a if block after “change y by () block”.
  14.  Here we have to check if the Tobi touches the Bell or not. for this, Goto sensing palette and add “touching ()?” block in the second if block and select bell from the dropdown. as shown below.
  15. If the tobi touches the Bell, we have to play the doorbell sound that we have added during the stage settings. Go to sound palette add block “play () until done” and select doorbell from the list.
  16. In the else part, tobi must glide to its initial location that x=0 y=0, from Motion palette, add “glide for () secs to x() y()” block. 

with this, your script is complete now.

 

Output

Output Gif will be updated soon.