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
- Go to Sprite button and add bell as a ew sprite.
- change the backdrop to “Sky blue 2”.
- Now you have two sprites on the stage “Tobi ” and “Bell”. change
- Select “Bell” and set its x value to 0 and y to 150. and size to 50% at the bottom of the stage.
- Change the size of Tobi to 80%
- Now the final thing adding the sound effect. go to sound block, search for bell, and add ‘Doorbll”.
Code
- Open Pictoblox and create a new file.
- Go to the board menu and select Quarky.
- Now after setting up the stage, select Tobi and start writing the below code for Tobi.
- From event palette, drag ” when flag clicked” block into th scripting area.
- 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.
- Create a variable as “Initial value ” to store the initial (or normal) value of the sensor.
- From Variable palette, drag “Set () to ()” and add after the goto block. select “initial value from the drop-down button.
- From Sensor palette of Quarky. place ” read analog sensor () at ()” block in place of 0. and choose generic from the list.
- Now add a forever block in the script and put “if-then-else” block inside the forever block.
- 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.
- 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.
- place the sensor value in place of 50 and set the required range. as shown below.
- 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”.
- 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.
- 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.
- 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.