Bluetooth Controlled LED | MindPlus Coding Kit for Arduino Started Tutorial E22

0 3832 Easy
projectImage

Chapter 10 Bluetooth Remote Control

Hands-On

Hardware connection

Plug the 3-pin interface of the LED module directly to the Digital Pin 10 of Arduino Uno.

projectImage

Hardware connection (LED-10)

Please match the colors when plugging

Programming

On the basis of controlling LEDs directly with UNO, we use the commands received by Bluetooth to control the LEDs, forming a relationship of “input-control-output”, as shown below:

projectImage

Previously, we learned how to control LEDs with button switches. The mechanism remains the same, but we are replacing the switches with Bluetooth for control.

projectImage
projectImage

1. Reference program

projectImage
projectImage

2. Modify app

Modify the sending signal in app Inventor and change the previous Hello and World to A and B.

 

projectImage

Then adjust the text of the buttons in the interface.

projectImage

3. Program’s effect

Press button A with the phone, the LED is on; press button B with the phone, the LED is off.

Further Exercise 

Everyone has learned to control LED lights with Bluetooth. Can we use Bluetooth to control other actuators?

icon Program 10-1 E22.rar 2.47MB Download(1)

Project 1 Bluetooth Controlled LED

In the previous section, we learned how to use a mobile phone to send data to Arduino via Bluetooth. Now, how to use these data to control the LEDs? In this section, we will use Bluetooth to turn on and off of LEDs.

Task Navigation

1. What is the baudrate?

2. What are ASCII characters?

3. Use your phone to light up the LEDs.

Key Points Analysis

1. baudrate

The official definition of the baudrate is the number of code elements transmitted per second. The communication between two modules only goes when the same baudrate is set on both sides. So at the beginning of the program we will set the baudrate. which is 115200 by default for BLE Bluetooth modules.

2. What are ASCII characters?

What is ASCII? ASCII (American Standard Code for Information Interchange) is a computer coding system based on the Latin alphabet. It is mainly used to display modern English and other Western European languages.

It is the most common information exchange standard and is equivalent to the international standard ISO / IEC 646. ASCII was first published as a standard in 1967, and was last updated in 1986, with a total of 128 characters defined so far.

Why makes ASCII? In computer, all data must be represented in binary during storage and computing (because computers use high level for 1 and low level for 0). For example, 52 letters such as a, b, c, d... (including uppercase), numbers such as 0, 1... and some commonly used symbols (such as *, #, @, etc.) are also represented in binary numbers when stored in the computer. However, everyone can have their standard on what binary number represents a certain symbol. And that standard is called an encoding. If we want to communicate with each other without confusion, we have to use the same encoding rules. Therefore, the relevant standardization organizations in the United States introduced the ASCII code, which specifies which binary numbers are used for the above-mentioned common symbols.

If we look at the data read by Bluetooth, we will see that we sent out letters but received a string of numbers. Why?

Because the original data received by Bluetooth transmission is ASCII values. They are numbers if not converted upon receiving. We can view the data of the corresponding character by looking at the ASCII conversion table.

projectImage

If we want to see characters, we can use the operator in Mind+ to convert them to characters.

projectImage

Command List

projectImage
License
All Rights
Reserved
licensBg
0