Table of Contents

set digital pin () output as ()

Description

This block enables users to set the digital state of an Arduino digital pin to either a High (5V) or Low (0V) voltage output. It can be used on the Arduino Uno, Mega, and Nano boards.

Available pins

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

Example

Learn about Arduino digital and analog pins and their functions as input or output for voltage levels.

Introduction

Digital pins

Arduino’s digital pins offer two voltage levels: HIGH (5V) or LOW (0V). When set to LOW, a pin provides 0V to external devices, while setting it to HIGH delivers 5V, enabling triggering of relays or LED illumination. Additionally, digital pins can function as input to read data from peripheral devices or as output to power sensors and other devices. On the other hand, analog pins are used to read analog values in the form of voltage levels ranging from 0V to 5V.

Analog pins

These are the pins that are used to read the analog values from devices in the form of voltage levels between 0v to 5v

Circuit Diagram

  1.  Resistance = 220Ω
  2. LED+ to pin 13 
  3. LED – to GND

Code

Now let’s connect our Arduino to Pictoblox and learn to code. 

  1. Open Pictoblox and choose Block coding.
  2. Go to “boards” and select “Arduino Uno” from the list
  3. From “connect,” choose the serial port, and then click on the “connect” button to establish the connection between Arduino Uno and your computer..
  4. Click on the event palette and drag “when the flag clicked.”
  5. From the control palette, drag the “forever” block and add it to the event block.
  6. From the Arduino palette, drag “set digital pin() output as ()” block into the forever block.
  7. Again from the control palette add the wait() block  into the forever block
  8. Repeat steps 6 and 7, setting the output as LOW this time.

Script

Output

 

Read More
All articles loaded
No more articles to load