Table of Contents

read status of digital pin ()

Description

The read state of digital pin () block is a boolean block available in Arduino Uno, Arduino Mega, and Arduino Nano boards. It reads the state of the digital pin on the hardware and returns either a True value (if the pin is set to “High”) or a False value (if the pin is set to “Low”).

  1. Available pins in Arduino Mega: 52 digital pins available for the user (2-53)
  2. Available pins in Arduino Uno: 12 digital pins available for the user (2-13)
  3. Available pins in Arduino Nano: 12 digital pins available for the user (2-13)

You can choose these pins from the drop-down menu.

Example

Discover the fundamentals of switches as electrical components that connect or disconnect conducting paths in circuits, enabling interruption or diversion of electric current.

introduction:

A switch is an essential electrical component that can disconnect or connect the conducting path in an electrical circuit, effectively interrupting or diverting the electric current. It plays a critical role in ON-OFF control for various applications across industries such as telecommunications, industrial control equipment, commercial devices, and home appliances.

Applications

The primary application of switches is to enable the ON-OFF control of circuits. They are widely used in industries including:

  1. Telecommunication: Switches play a key role in telecommunication equipment, allowing users to turn devices ON or OFF.
  2. Industry Control Equipment: Industrial machinery and equipment often rely on switches for circuit control and operation.
  3. Commercial Equipment: Switches are used in various commercial devices to facilitate user control and energy-saving features.
  4. Home Appliances: Household appliances such as fans, lights, and kitchen appliances utilize switches for convenient operation.


Circuit Diagram

Code

  1. Add the “when flag clicked” event from the event palette.
  2. Use the “go to x() y()” block from the motion palette and set the coordinates to 0,0..
  3. Introduce the “forever” block from the control palette.
  4. From control palette select if -else condition, use block read the state of digital pin 6 of Arduino.
  5. Add the “if – else” condition block from the control palette to read the state of digital pin 6 of Arduino.
  6. If the button is pressed (state of digital pin 6 is high), make Tobi jump by changing y() by 40 steps,  If the button is not pressed (state of digital pin 6 is low), make Tobi jump back to the original position by using the “go to x() y()” block and setting the coordinates to 0,0.
  7. Insert this section of code inside the “forever” block and merge all the parts.

Script

Output

Read More
All articles loaded
No more articles to load