echo '' ;

Arduino Tutorial – Random Number Generator

This tutorial is about “Arduino Tutorial – Random Number Generator”. A Random Number Generator (RNG) is a computational or physical process designed to generate a sequence of numbers that lack any pattern or predictability. These numbers are typically used in various fields such as cryptography, simulations, gaming, and statistical sampling.

Types of RNGs

RNGs play a vital role in ensuring fairness in games, maintaining security in cryptographic systems, and simulating complex phenomena in scientific research and engineering simulations.

Pseudorandom Number Generators (PRNGs): These algorithms generate numbers that appear random but actually derive from an initial value called a seed. PRNGs are deterministic, meaning if you know the seed, you can reproduce the sequence of numbers. Software applications widely use them due to their efficiency and ease of implementation.

True Random Number Generators (TRNGs): TRNGs generate numbers based on unpredictable physical processes, such as radioactive decay, thermal noise, or atmospheric noise. TRNGs provide higher security and are common in cryptographic applications where unpredictability is crucial because they rely on inherently random phenomena.

Use of Random Number Generator

FieldUses
CryptographyGenerating cryptographic keys, initialization vectors, and nonces
Ensuring the security of encryption algorithms and digital signatures
GamingSimulating chance-based events in video games, casinos, and gambling platforms
Ensuring fairness in gaming outcomes
Simulation and ModelingGenerating random inputs for simulations across multiple disciplines
Adding stochastic elements to models for realism
Statistical SamplingGenerating random samples for hypothesis testing and estimation
Reducing bias in statistical analyses
Monte Carlo MethodsEstimating complex mathematical problems using random sampling
Simulating probabilistic systems
Machine LearningRandom initialization of model parameters
and Artificial IntelligenceShuffling datasets for training
Introducing randomness in optimization algorithms
Numerical AnalysisImproving performance and convergence properties of algorithms

Prerequisites

Before start to learn, you should know below topics. If you know already, please go further

Components Required for Arduino Tutorial Random Number Generator

  • Arduino  Uno Board (You Can use any other arduino boards*) – 1 Nos

Code : randomSeed()

Arduino Tutorial Random Number Generator

long randNumber;

void setup(){
  Serial.begin(9600);
  randomSeed(analogRead(0));
}

void loop(){
  randNumber = random(300);
  Serial.println(randNumber);

  delay(50);
}

Code Explanation

Component/FunctionPurpose
long randNumber;Variable declaration to store the generated random number
void setup()Function that runs once to initialize the Arduino board and setup necessary configurations
Serial.begin(9600);Initializes serial communication with the computer at a baud rate of 9600 bits per second
randomSeed(analogRead(0));Seeds the random number generator with a value obtained from reading analog pin 0
void loop()Function that runs continuously after the setup() function, where the main code resides
randNumber = random(300);Generates a random number between 0 and 299 and assigns it to randNumber variable
Serial.println(randNumber);Prints the generated random number to the serial monitor followed by a newline character
delay(50);Inserts a delay of 50 milliseconds between each iteration of the loop

Code: random()

long randNumber;

void setup(){
  Serial.begin(9600);
  randomSeed(analogRead(0));
}

void loop(){
  randNumber = random(300);
  Serial.println(randNumber);

  delay(50);
}

Code Explanation

Component/FunctionPurposelong randNumber;Declares a variable to store the generated random numbervoid setup()Initializes the Arduino board and sets up necessary configurationsSerial.begin(9600);Initializes serial communication with the computer at a baud rate of 9600 bits per secondrandomSeed(analogRead(0));Seeds the random number generator with a value obtained from reading analog pin 0void loop()Executes the main code continuously after the setup, where the random number generation occursrandNumber = random(300);Generates a random number between 0 and 299 and assigns it to randNumber variableSerial.println(randNumber);Prints the generated random number to the serial monitor followed by a newline characterdelay(50);Adds a delay of 50 milliseconds between each iteration of the loop


NEXT

Arduino-Get Start
Arduino Interface
Arduino Interface-LED
Arduino Interface-Button
Arduino Interface -Buzzer
Arduino Interface-ADC
Arduino Interface-UART(Serial)
Arduino Interface-PWM
Arduino Interface-RGB LED
Arduino Interface-LCD
Arduino Tutorials
Random Number Generator
Voltage Measurement
Arduino Projects
Therimine
Water Flow Meter
Servo Control Using Accelerometer ADXL345
Others
Arduino-Course
Arduino-Sitemap
Arduino-FAQ

ESP8266 – Getting Started

ESP8266 is a powerful microcontroller with built-in WiFi. Whether you’re a beginner or an expert, this is the right place to enhance your knowledge about ESP8266 and its applications. Nowadays, ESP8266 is highly renowned for its versatility and is utilized in numerous applications such as home automation, smart plugs and lights, mesh networks, industrial wireless control, baby monitors, IP cameras, sensor networks, wearable electronics, WiFi location-aware devices, security ID tags, and WiFi position system beacons. It is a popular chip in the Internet of Things world. Before diving into learning about ESP8266, it’s essential to understand the manufacturer, Espressif.”

Read more… →

Embedded Protocol – One Wire

One Wire” refers to a communication protocol developed by Dallas Semiconductor (now Maxim Integrated) that allows multiple devices to communicate over a singleWire using a master-slave architecture. It enables bidirectional communication and power delivery over a singleWire, simplifying wiring and reducing hardware complexity in certain applications.

The protocol operates by sending and receiving data serially using a singleWire, which also serves as a ground reference. Each device on the One Wire network has a unique 64-bit address, allowing the master device to identify and communicate with individual slaves. Additionally, One Wire devices can be powered directly from the data line, eliminating the need for separate power connections in some cases.

One Wire is commonly used in applications where minimizing wiring and hardware complexity is essential, such as temperature sensing, identification (e.g., RFID tags), and small-scale data logging. It’s particularly popular in applications where running multiple wires is impractical or cost-prohibitive, such as in distributed sensor networks or in situations where space is limited.

Overall, One Wire offers a simple and cost-effective solution for connecting multiple devices over a single wire, making it a valuable tool in various embedded systems and IoT applications.

  • Above image link
  • This protocol is serial communication protocol
  • Its developed by Dallas Semiconductor.
Read more… →

ESP8266 – FAQ

Here are some (frequently asked questions) FAQ about ESP8266. These FAQs cover some of the common questions about ESP8266, but if you have any specific questions or need more information, feel free to Refer to All ESP8266 Sections! (ESP8266 FAQ)

Read more: ESP8266 – FAQ

What is ESP8266?

  • Espressif Systems developed ESP8266, a low-cost Wi-Fi microchip, making it widely utilized in IoT (Internet of Things) projects due to its affordability and versatility.

Key features of ESP8266?

  • Key features of ESP8266 include Wi-Fi connectivity, low power consumption, GPIO pins for interfacing with external devices, and support for various programming languages like Arduino, Lua, and MicroPython.

What programming languages can I use with ESP8266?

  • ESP8266 can be programmed using languages like Arduino (C/C++), Lua, and MicroPython. Each language has its advantages and is suitable for different types of projects and developers.

How do I program ESP8266?

  • ESP8266 can be programmed using the Arduino IDE with the help of the ESP8266 board package, or using other development environments like PlatformIO. Additionally, Lua and MicroPython can be used for programming ESP8266 devices.

What are some common applications of ESP8266?

  • Common applications of ESP8266 include IoT devices such as smart home systems, environmental monitoring devices, Wi-Fi controlled appliances, weather stations, and more.

Can ESP8266 act as a web server?

  • Yes, ESP8266 can act as a web server, allowing it to serve web pages, handle HTTP requests, and communicate with web clients over Wi-Fi.

Is ESP8266 suitable for battery-powered applications?

  • While ESP8266 offers low power modes and can be used in battery-powered applications, its power consumption may not be as low as other microcontrollers specifically designed for low power consumption.

Can ESP8266 communicate with other microcontrollers or devices?

  • Yes, ESP8266 can communicate with other microcontrollers and devices using various communication protocols like SPI, I2C, UART, and MQTT over Wi-Fi.

FAQ: What is NodeMCU?

  • NodeMCU is a firmware platform for ESP8266-based devices, providing a Lua-based scripting language for easy development of IoT applications.

Where can I find documentation and resources for ESP8266?

  • Documentation, tutorials, and resources for ESP8266 are available on the official Espressif website, community forums, GitHub repositories, and various online tutorials and blogs.

FAQ: Where to Buy ESP8266 Modules?

Before buying an ESP8266 module, it’s important to know the different kinds of modules available and their features. You can find detailed information about this in the post linked here. By reading that post, you’ll get an idea of which ESP8266 module is suitable for your requirements. If you’re a beginner, I recommend buying the NodeMCU Dev Board. Nowadays, everything is available online, so there’s no need to worry about purchasing anything. If you order online, you’ll receive your item within a few days. The best place to buy an ESP8266 is on eBay because many sellers are offering different prices ranging from low to high. You can also try other platforms like Amazon and AliExpress. Click the links below to buy an

ESP8266 online:


What is the main difference b/w nodemcu and ESP-WROOM-02?

  • Nodemcu
    • NodeMCU is a lua based open source platform for ESP8266.
    • nodemcu dev kits it’s a development kit of NodeMCU
  • ESP8266 Wroom-02
    • ESPressif is the maker and manufacturer of ESP8266 chips.
    • ESP8266 WROOM-02 is development board of Espressif.

Coding wise any deference is there between ESP-Wroom-02 and NdeMCU?

  • Answer is no.
  • Because hardware components may vary from different kind of ESP8266 boards like antenna design, PCB design, PCB board Layer size, Flash memory GPIO pin extensions and Board size.
  • You first choose your programming platform (NodeMCU, Arduino, Direct C, Mongoose OS, MicroPhython, ESP8266 Basic). ESP8266 Supports many different programming language like C, C++, Lua, JavaScript, Python and many more.

Next Topic

ESP8266 FAQ

ESP8266 Get Start
ESP8266 Various Boards
ESP8266 Programming Methods
ESP8266 Various Programmer
ESP8266 Build&Flash Firmware
ESP8266 Resource
ESP8266 FQA
ESP8266 MQTT broker BONDAR.
ESP8266 Platforms
ESP8266 Arduino-Core
ESP8266 AT-Commands
ESP8266 Mongoose OS
ESP8266 NodeMCU
Others
ESP8266 Sitemap
ESP8266 All post

Arduino – Course

Requirements

  • A Windows, Mac or Linux computer
  • An Arduino Uno
  • Electronics parts like resistors, LEDs, sensors, as listed in Section 1 of the course
  • Essential tools: a mini breadboard, jumper wires, a multimeter, a soldering iron and solder, wire cutter
  • Be excited about electronics!

Read more… →

Embedded Interface – Touch Keypad

A touch keypad is an input device that allows users to interact with electronic devices by touching designated areas on its surface. It typically consists of a panel with sensitive touch sensors beneath, capable of detecting the presence and location of touch inputs. Touch keypads are commonly used in various electronic devices such as smartphones, tablets, ATMs, point-of-sale terminals, and household appliances like microwave ovens and washing machines. They offer advantages like sleek design, ease of use, and versatility in terms of layout and functionality.

Read more: Embedded Interface – Touch Keypad

TTP226

TTP226 based Module – 1

Here is the Specifications

FeatureDescription
On board 8 key TTP226 capacitive touch induction IC.Allows for capacitive touch sensing with 8 keys.
On board 8-way level indicator.Features an 8-way level indicator on board.
Working voltage2.4 V to 2.4 V
ModulesAllows for setting output mode, key output mode, the longest time, and fast/low power output.
PCB board sizeDimensions: 47.5 mm (width) x 46 mm (height).
Read more… →

ESP8266 MQTT broker BONDAR

The ESP8266 can indeed be programmed to act as an MQTT broker, allowing it to handle messaging between different devices in a network using the MQTT protocol. Will Discuss “ESP8266 MQTT broker BONDAR”.

Get Start of ESP8266 MQTT broker BONDAR

Create an account

  • Create an account in here
  • Activate your iotcentral account

Download Bin FIle

Flash the Bondar Firmware

  • your ESP8266 starting from address 0x0. (Use esptool.py or ESP Flash Download Tool)
  • For Linus
    • sudo esptool.py -p /dev/ttyUSB0 –baud 9600 write_flash -fs 32m-c1 -fm dio -ff 40m 0x00000 bondar.bin

ESP8266 Configuration

  • ESP8266 will start as Access Point mode. and named as Bondar_XXXXXXXXX  . (Ex refer Below image : Bondar_2e3ae80cb19a ) and should use default password 12345678
  • Now connect that AP Network (Bondar_2e3ae80cb19a ) with your laptop or mobile.
  • Go to 192.168.4.1 in your browser and you will get a configuration page. Then enter your wifi Credential and your he user and password used on IoTCentral.eu
  • Reset the ESP8266 by Click button and also unplug and re-plug the power cable (I recommend you to unplug and then plug the power cable).
  • After Rest you can see when did soft web browser reset button

IoTCentral.eu Account Details

  • Login to your home page on IoTCentral.eu
  • You will see your allocated topic
  • Use allocated_topic/your_topics to connect to iotcentral.eu:1883 and /allocated_topic/your_topic to connect from your Wi-Fi network.

Note :   Always use your email address and the password used on IoTCentral.eu to publish and subscribe. In this way your data is protected and no one will get access to your data since the topic is secret and you are using your username and password to publish and subscribe to the cloud.


Embedded Interface – MCP23017

Microchip Technology manufactures the MCP23017, a popular integrated circuit (IC) frequently utilized to expand the input/output (I/O) capabilities of microcontrollers. This IC provides an easy way to add more digital I/O ports to a microcontroller using the I2C protocol. With the MCP23017, you can add up to 16 digital input/output pins to your microcontroller with just two I2C pins, which is quite efficient in terms of pin usage.

Read more: Embedded Interface – MCP23017

In situations where the microcontroller’s built-in GPIO pins prove insufficient for the task at hand, various electronic projects commonly employ the MCP23017. For instance, it finds application in hobbyist projects, industrial automation, and DIY electronics alike.

The MCP23017 enables the connection of multiple devices on the same I2C bus by featuring configurable pull-up resistors, interrupt capabilities, and a programmable hardware address. This versatility makes it a favorite among hardware hackers and embedded systems enthusiasts.

Features

  • 16-bit input/output port expander with interrupt output
  • 16 bit serial interface
  • Cascadable for up to 8 devices on one bus
  • 25mA sink/source capability per I/O
  • Supports 100kHz, 400kHz and 1.7MHz I2C™Compatible compatible modes
  • The address for MCP23017 (between 0x20 and 0x27)

Pin Details

INTA and INTB

  • There are two interrupt pins, INTA and INTB, that can be associated with their respective ports, or can be
    logically OR’ed together so that both pins will activate if either port causes an interrupt.

(IODIRA/B)

  • system master can enable the I/Os as either inputs or outputs by writing the I/O configuration bits
    IOCON.BANK – The MCP23X17 can beconfigured to operate in the 8-bit or 16-bit modes via “IOCON.BANK.”

Data Sheet

Examples

Reference Link

Next Topic

Embedded Interface 7 Segment (Add Soon)
Embedded Interface ADC (Add Soon)
Embedded Interface Button (Add Soon)
Embedded Interface EEPROM (Add Soon)
Embedded Interface LCD (Add Soon)
Embedded Interface LCD HD44780 (Add Soon)
Embedded Interface LED
Embedded Interface MCP23017
Embedded Interface Motor (Add Soon)
Embedded Interface PCF8574 and PCF8574A
Embedded Interface RTC (Add Soon)
Embedded Interface Switch
Embedded Interface Touch Kypad
Embedded Interface RGB LED (Add Soon)

Embedded Interface – EEPROM

EEPROM stands for Electrically Erasable Programmable Read-Only Memory. It’s a type of non-volatile memory that can store small amounts of data even when power is removed. EEPROMs are commonly used in applications where persistent storage of configuration settings or small amounts of user data is required, such as in microcontrollers, embedded systems, and electronic devices like USB flash drives and SD cards. Unlike traditional ROM (Read-Only Memory), EEPROM can be electrically erased and reprogrammed multiple times, making it flexible and suitable for applications that require frequent updates to stored data.

Feature

One prominent feature of EEPROM is its ability to be electrically erased and reprogrammed, allowing for multiple read-write cycles. This feature makes EEPROM ideal for storing data that may need frequent updates or modifications, such as configuration settings or user preferences in electronic devices. Additionally, EEPROMs typically offer low-power consumption, fast access times, and compatibility with a wide range of microcontrollers and electronic systems. Moreover, they often have a relatively high endurance, allowing them to withstand many read and write cycles before wearing out.

AT24C128 I²C EEPROM Feature

  • Voltage
    • Low Voltage (1.8v to 3.6v)
    • Standard Voltage (2.7V to 5.5V)
  • Memory
    • 128K (16,384 x 8)
    • 256K (32,768 x 8)
  • I²C Interface (Bi-Directional data transfer protocol)
  • Speed
    • 1MHz(5v)
    • 400KHz(2.7v, 2.5v)
    • 100kHz(1.8v)
  • High Reliablility
    • 1 Million write cycles of endurance
    • 40 years of Data Retention

EEPROM Datasheet

Next Topic

Embedded Interface 7 Segment (Add Soon)
Embedded Interface ADC (Add Soon)
Embedded Interface Button (Add Soon)
Embedded Interface EEPROM (Add Soon)
Embedded Interface LCD (Add Soon)
Embedded Interface LCD HD44780 (Add Soon)
Embedded Interface LED
Embedded Interface MCP23017
Embedded Interface Motor (Add Soon)
Embedded Interface PCF8574 and PCF8574A
Embedded Interface RTC (Add Soon)
Embedded Interface Switch
Embedded Interface Touch Kypad
Embedded Interface RGB LED (Add Soon)

Electronic Devices – Resistor

The resistor is a passive two-terminal electronic components. It function is to limit or reduce(resist) the flow of current or divide the voltage in a circuit. The unit of the resister is ohm(Ω). The resistance r of any material is proportional to its length and inversely proportional to its area of cross-section A.

R=ρl/A Ω

ρ=specific resistance or resistivity of the material.


Symbol


Type

  • Fixed Type
    • Wire wound resistor
    • Carbon film resistor
    • Metal film resistor
    • Carbon composition resistor
    • Carbon resistor
    • Film type resistor
    • Chip resistor
  • Variable Type
    • Rheostat
    • Potentiometer
    • Trimmer
    • Preset

Color Code

ColorDigit valueMultiplierMultiplied OutTolerance
Black01001 
Brown110110 
Red2102100 
Orange31031,000 
Yellow410410000 
Green5105100,000 
Blue61061,000,000 
Violet710710,000,000 
Gray8108100,000,000 
White91091,000,000,000 
Gold   ±5%
Silver   ±10%

Power

Measuring power across a resistor (Ohm’s Power Law)


Ohms Law

Ohm’s law describes the fundamental behavior of
resistors.


LED Current Limiting

For example, assume you have a 9V battery to power an
LED. If your LED is red, it might have a forward voltage around 1.8V. If you
want to limit the current to 10mA, use a series resistor of about 720Ω.


Kirchhoff’s Law

Kirchhoff’s law can be used to analyses networks
of resistors.


Resistor networks


Voltage Dividers


Resistivity properties of materials

Materialρ (Ωm) at 20°Cσ (S/m) at 20°CTemperature coefficient (1/°C) x10^-3
Silver1.59×10−86.30×1073.8
Copper1.68×10−85.96×1073.9
Gold2.44×10−84.10×1073.4
Aluminum2.82×10−83.5×1073.9
Tungsten5.60×10−81.79×1074.5
Zinc5.90×10−81.69×1073.7
Nickel6.99×10−81.43×1076
Lithium9.28×10−81.08×1076
Iron1.0×10−71.00×1075
Platinum1.06×10−79.43×1063.9
Tin1.09×10−79.17×1064.5
Lead2.2×10−74.55×1063.9
Manganin4.82×10−72.07×1060.002
Constantan4.9×10−72.04×1060.008
Mercury9.8×10−71.02×1060.9
Nichrome1.10×10−69.09×1050.4
Carbon (amorphous)5×10−4 to 8×10−41.25 to 2×103-0.5


Application of Resistors

  • variable resister is used in volume control in
    the TV application,
  • LED Current Limiting

Examples


Example 1

find the resistance of a copper
wire of 0.75km long and having a cross sectional area of 0.01cm2.
(take ρ=1.72×10-8ohm-m).

ANS=12.9ohm


Example 2

find the cross sectional area of
an aluminium wire of 700m long and having a resistance of 0.24ohm (take ρ=2.83×10-8ohm-m)

ANS=8.254×10-5m2.


Example 3

 if a R = 300 ohm is attached
across the terminals of a V = 12 volt battery, then a current  of (V/R)12 / 300 = 0.04 amperes flows
through that.


Example 4 (Ohm’s law equations)

Consider
a 1-ohm resistor in a circuit with a voltage drop from 100V till 10V across its
terminals. What is the current through the resistor?
 The
triangle reminds us that:


Example 5 (Ohm’s law equations)

Consider
a 10-ohm resistor in a circuit subject to a current of 2 Ampere and a voltage
of 120V. What is the voltage drop across the resistor?
 Using
the triangle shows us that:


Answerer
Thus the voltage at the end terminal is 120-20
= 100 V.


Example 6 (Ohm’s Power Law)

What must be the minimal power rating of this resistor?


Answer:
According to the wheel, P=I^2*R= 0.100^2*50=0.5 W. So the minimal power
rating should be at least 0.5W, but recommended is to go high above this value
for extra reliability and lifetime.


Example 7 (Ohm’s Power Law)

What is the current in the circuit?

This is a basic example of Ohm’s law. Voltage and resistance are known,
so we can calculate current with the equation:

I=V/R=6/1.2=5 A.


Example 8 (Ohm’s Power Law)

An electric heater (resistor) with a consumption of 1kW
is connected in a circuit with 8A current. What is the voltage drop over the
heater?

Voltage can be expressed in current and power with the formula:
V=P/I= 1000/8=125 V


Reference Website


Video tutorial

Basic Electricity – Resistance and Ohm’s law

ESP8266 Arduino-Core Tutorial – Web Server

TCP Server Listener

The below Arduino code will also create a server and Access Point in ESP8266 which will continuously listen for a connection.

Code

//www.ArunEworld.com

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>

const char *ssid = "ArunEworld";
const char *password = "Arun";

ESP8266WebServer server(80);

void handleRoot() 
{
    server.send(200, "text/html", "<t1>ArunEworld</t1>");
    server.send(200, "text/html", "<h1>ArunEworld : TCP WebServer Listener</h1>");
    server.send(200, "text/html", "<h2>You are connected</h2>");
}

void setup()
{
    delay(1000);
    Serial.begin(115200);
    Serial.println();
    Serial.print("Configuring access point...");
    WiFi.softAP(ssid, password);
    IPAddress myIP = WiFi.softAPIP();
    Serial.print("AP IP address: ");
    Serial.println(myIP);
    server.on("/", handleRoot);
    server.begin();
    Serial.println("HTTP server started");
}

void loop() 
{
    server.handleClient();
}

After uploading this sketch, you can find a new Access Point named “test” from your Laptop or PC.

Result


 

ESP8266 NodeMCU Project – Home Automation

Home automation is the process of controlling various devices and systems in your home through a centralized control system. With the advancement of technology, home automation has become more accessible and affordable for homeowners.The ESP8266 NodeMCU is a popular choice for home automation projects due to its built-in Wi-Fi capability and compatibility with various sensors and actuators. In this project, we will explore how to set up a basic home automation system using the ESP8266 NodeMCU.

Read more… →

Embedded Interface – RTC

Application

  • Whats-app
    • Every mobile has an in-build RTC. Whatsapp is taking current time from mobile system processor using RTC function and send to WhatsApp server. Once Receptive is online he will receive the  message with a timestamp

Next Topic

Embedded Interface 7 Segment (Add Soon)
Embedded Interface ADC (Add Soon)
Embedded Interface Button (Add Soon)
Embedded Interface EEPROM (Add Soon)
Embedded Interface LCD (Add Soon)
Embedded Interface LCD HD44780 (Add Soon)
Embedded Interface LED
Embedded Interface MCP23017
Embedded Interface Motor (Add Soon)
Embedded Interface PCF8574 and PCF8574A
Embedded Interface RTC (Add Soon)
Embedded Interface Switch
Embedded Interface Touch Kypad
Embedded Interface RGB LED (Add Soon)

Embedded Interface – RGB LED

PWM -Pulse width Modulation

RGB LED

 

Type of RGB LED


 

Next Topic

Embedded Interface 7 Segment (Add Soon)
Embedded Interface ADC (Add Soon)
Embedded Interface Button (Add Soon)
Embedded Interface EEPROM (Add Soon)
Embedded Interface LCD (Add Soon)
Embedded Interface LCD HD44780 (Add Soon)
Embedded Interface LED
Embedded Interface MCP23017
Embedded Interface Motor (Add Soon)
Embedded Interface PCF8574 and PCF8574A
Embedded Interface RTC (Add Soon)
Embedded Interface Switch
Embedded Interface Touch Kypad
Embedded Interface RGB LED (Add Soon)

Arduino Tutorial – Voltage Measurement

Circuit

 

Schematics

 

Code

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
  float voltage = sensorValue * (5.0 / 1023.0);
  // print out the value you read:
  Serial.println(voltage);
}