Serial and Bluetooth

Updated: Feb 26

In this tutorial, we are going to see how to use serial and Bluetooth.

  • In the first example, we will increment one number variable and print it on a serial monitor.

  • In the second example, we are going to receive a character from serial or Bluetooth and turn on different LEDs according to the letter received on the serial or Bluetooth



blocks We are going to use

You can find serial/Bluetooth related blocks in the 'Serial' category as shown in the following image

Serial catagory

If a Bluetooth module is attached and something is printed on a serial, that will be sent to serial and Bluetooth. But character can be received via Bluetooth and not via serial monitor because

if bluetooth module is attached, then bluetooth will have higher priority than the serial monitor for receiveing the character


1. Serial print

In this block, we can input a text which will be printed on serial


2. Serial print number

In this block, we can input a number that will be printed on serial. This number can be integer or real.


3. read character on serial/Bluetooth

These both the blocks are the same and can be used interchangeably. This block is used to get serial/Bluetooth received character in a variable


4. character

This block is used to input a single character.


 


Example 1

In this example, we will increment one number variable and print it on a serial monitor.


serial print blocks
serial_print
.txt
Download TXT • 3KB

To open the serial monitor, click on the serial monitor icon in Nirmiti IDE. The serial monitor button is pointed using the red arrow in the following image. select the com port and baud rate equal to 9600 and press 'connect'


serial monitor button
output on serial monitor














To receive data on mobile via Bluetooth, connect the Bluetooth module as shown in the image below

Bluetooth module mounted on Nirmiti base shield

Use the 'Serial Bluetooth Monitor' app for connecting mobile with Nirmiti wirelessly via Bluetooth.

output on app



 


Example 2

In this example, we are going to receive a character from serial or Bluetooth and turn on different LEDs according to the letter received on the serial or Bluetooth.

In the following blocks, we turn ON the green LED if character 'O' is received and turn OFF if character 'F' is received


Serial receive blocks
serial_receive
.txt
Download TXT • 3KB


To send the character to the Nirmiti board using Serial monitor, write it in the transmitter field as shown in the following image and press the 'send button

Serial monitor transmitter

For sending the character to the Nirmiti board using the Serial Bluetooth monitor app, write it in the transmitter field as shown in the following image and press the 'send button

Trasmitter in Serial Bluetooth Monitor app





24 views0 comments

Recent Posts

See All