0% found this document useful (0 votes)
18 views27 pages

Arduino Serial Communication

The document discusses serial communication and how it can be used to control LEDs using an Arduino and Bluetooth module. Serial communication transmits data sequentially over a single channel and is commonly used for communication between microcontrollers and other devices. An Arduino can send and receive serial data to control LEDs by color in response to commands sent via Bluetooth from a computer or other device.

Uploaded by

Zayshin
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
Download as pptx, pdf, or txt
0% found this document useful (0 votes)
18 views27 pages

Arduino Serial Communication

The document discusses serial communication and how it can be used to control LEDs using an Arduino and Bluetooth module. Serial communication transmits data sequentially over a single channel and is commonly used for communication between microcontrollers and other devices. An Arduino can send and receive serial data to control LEDs by color in response to commands sent via Bluetooth from a computer or other device.

Uploaded by

Zayshin
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1/ 27

ARDUINO

SERIAL COMMUNICATION
WHAT IS SERIAL COMMUNICATION?
Serial communication is a method of
transmitting data between electronic
devices on bit a time over a
communication channel or wire.
WHAT IS SERIAL
COMMUNICATION?
WHAT IS SERIAL COMMUNICATION?
Serial communication sends data sequentially,
using only one channel. This method is
commonly used in various application,ranging
from simple communication between two
microcontrollers to complex data between
computer peripherals
WHAT IS SERIAL COMMUNICATION?
Serial communication sends data sequentially,
using only one channel. This method is
commonly used in various application,
ranging from simple communication between
two microcontrollers to complex data between
computer peripherals
SIGNIFICANCE OF SERIAL
COMMUNICATION
SIGNIFICANCE OF SERIAL
COMMUNICATION
• Communication with peripherals
• Programming and debugging
• PC connectivity
• Expansion and networking
• Wireless communication
• Data Transfer and Integration
ARDUINO SERIAL
COMMUNICATION BASICS
Serial.begin() function and its parameters
• Serial.begin() is a function used to initialize serial
communication on Arduino. It configures the baud
rate(data transfer speed ) for communication.

• baudRate specifies the baud rate at which data will


be transmitted, measured bits per
second(bps).Arduino board and the device it
communicates with must be configured with the same
baud rate for successful communication.
Serial.begin() function and its parameters
• Serial.print() and Serial.println() are functiuons used
to send data( numbers, characters, or strings) from
Arduino to the serial port.

• Serial.print() sends data without appending a newline


character .

• Serial.println() sends data and appends a newline


character(\n) to the end of the data, causing the next
output to start on a new line.
Serial.begin() function and its parameters

Syntax

Serial.print(data);
Serial.println(data);

Data: the variable, number, character, or


string to be sent over the serial port.
Reading data from serial port:Serial.read() function
• Serial.read() is a function used to read incoming data
from the serial port( RX pin) of Arduino.
It returns the first byte of incoming serial data available.
Syntax:
Serial.read();
This function is ofthen used within a conditional
statement to check if serial data is available before
attempting to read it.
Handling incoming and outgoing data streams
• Arduino can simultaneously send and receive data
over the serial port.
• Incoming data is read using ‘Serial.read()’ and
process accordingly.
• Outgoing data is sent using ‘Serial.print()’ or
‘Serial.println()’ functions based on the requirements.
• Developers can implement various algorithms logic to
handle incoming and outgoing data strams as per the
project needs.
Control LED using Serial Communication
Control LED using Serial Communication
Control LED using Serial Communication
Control LED using Serial Communication
if ‘r’
turn on red led
turn off green and blue led
If ‘g’
turn on green led
turn off red and blue led

If ‘b’
turn on blue led
turn off green and red led

If ‘s’
turn off all leds
Control LED using Serial Communication(CMD)

powershell
[System.IO.Ports.SerialPort]::getportnames()
$port= new-Object System.IO.Ports.SerialPort COM#,9600,None,8,one

$port.open()
$port.WriteLine()
$port.ReadLine()
$port.close()
Control LED using Serial Communication(CMD)
ARDUINO BLUETOOTH MODULE
1. Key/EN: It is used to bring Bluetooth module in AT commands mode. If Key/EN pin is
set to high, then this module will work in command mode. Otherwise by default it is in
data mode. The default baud rate of HC-05 in command mode is 38400bps and 9600 in
data mode.
HC-05 module has two modes,
1. Data mode: Exchange of data between devices.
2. Command mode: It uses AT commands which are used to change setting of HC-
05. To send these commands to module serial (USART) port is used.
2. VCC: Connect 5 V or 3.3 V to this Pin.
3. GND: Ground Pin of module.
4. TXD: Transmit Serial data (wirelessly received data by Bluetooth module transmitted
out serially on TXD pin)
5. RXD: Receive data serially (received data will be transmitted wirelessly by Bluetooth
module).
6. State: It tells whether module is connected or not.
ARDUINO BLUETOOTH MODULE

HC-05 module Information


•HC-05 has red LED which indicates connection status, whether the Bluetooth is
connected or not. Before connecting to HC-05 module this red LED blinks continuously in
a periodic manner. When it gets connected to any other Bluetooth device, its blinking slows
down to two seconds.
•This module works on 3.3V. We can connect 5V supply voltage as well since the module
has on board 5 to 3.3 V regulator.
•As HC-05 Bluetooth module has 3.3V level for RX/TX and microcontroller can detect 3.3
V level, so, no need to shift transmit level of HC-05 module. But we need to shift the
transmit voltage level from microcontroller to RX of HC-05 module.
•The data transfer rate of HC-05 module can vary up to 1Mbps is in the range of 10
meters.
ARDUINO BLUETOOTH MODULE
Control LED using Serial
Communication(Bluetooth
module)

You might also like