Table of Contents

read analog pin ()

Description

This block reads the value from the analog pins of boards such as Arduino Uno, Arduino Mega, or Arduino Nano. It returns the 10-bit resolution of the analog pin, with a range of 0 – 1023, which is mapped to the voltage of the pin (usually 0 – 5V). For example, if the value received is 512, then the voltage is roughly 2.5V.

Available pins:

  1. Arduino Uno: 6 analog pins available for the user, A0 to A5
  2. Arduino Mega: 6 analog pins available for the user, A0 to A5
  3. Arduino Nano: 8 analog pins available for the user, A0 to A7

Example

Learn about the fundamental working principle of a potentiometer and its versatile applications as a variable resistor or voltage divider

Potentiometer and It’s working

A potentiometer is a crucial three-terminal resistor featuring a sliding or rotating contact that forms an adjustable voltage divider. When using only two terminals (one end and the wiper), it functions as a variable resistor or rheostat. The potentiometer’s three pins consist of two connected to the resistive element (blue and green) and one connected to the adjustable wiper (black). The potentiometer can serve as a rheostat to vary resistance or as a voltage divider. The position of the wiper determines the amount of resistance imposed on the circuit, as demonstrated in the figure below.

Circuit Diagram

Code

  1. From the event palette add when flag clicked event.
  2.  Add forever loop 
  3.  From looks palette add say block.
  4. Now add read analog pin A0 in this say block.

Script

Output

Read More
All articles loaded
No more articles to load