Arduino Delphi Serial Communication Arduino Bluetooth

Arduino Delphi Serial Communication Arduino Bluetooth Rating: 5,0/5 5673 votes

Apr 25, 2012  In today's Arduino tutorial, we go over the Uno's built in serial communication. We look at talking to the Arduino from the computer and vice versa, the.

At this point you should have a robot that can think on its own, we need to be able to tap into its thought process. See what he sees. Make some of his decisions for him. In essence, we need to be able to guage his intelligence to make him more intelligent and increase his efficiency. With serial communications we can do two things: We can either send commands or receive data. Here are some examples to use with Serial communications: 1. Find out what values your sensors are outputting.

Find out if your robot is making the right decisions (Drugs = FALSE;) 3. Change the value of a variable. Control your robot's movement or other things in your robot. Little mix touch download musicpleer. Serial communication works on 1s and 0s. Also known as binary, the Arduino sends these 1s and 0s (bits) one by one, or Serially. These bits are sent in the form of Highs(1) and Lows(0). These bits form together and turn into bytes.

A byte is composed of 8 bits. Here's a little tutorial on binary: Each bit represents a certain number to add. The first bit (Far right) represents the ones place, similar to the common decimal system. 1 = 1 and 0 = 0. The next bit's value is multiplied by two, so: 10 = 2, 11 = 3, 00 = 0 and 01 = 1. Similarly: 100 = 4, 1000 = 8, 10000 = 16, 100000 = 32, 1000000 = 0 = 128.

Now these bits can form a value up to 255 (11111111). This value can be turned into ASCII encoded symbols and letters.

Updated: Added example 2 In the post I explained how to connect a HC-05 to a HC-06 so that when powered they automatically made a connection. Here we look at using that connection to get Arduinos talking over Bluetooth. Before continuing you need to have the Arduinos and BT modules set up as per the previous post. Here I am using 2 HC-05s. One in master mode the other in slave mode. The setup process for the slave mode HC-05 is the same as the HC-06 in the previous post. Set Up I am using 5V Arduino Nanos but any kind of 5V AVR based Arduino can be used.

I have designated one of the Arduinos as the master device. This is the one that initiates the connection and in the first example it is the one that sends the commands. Having a master and slave setup makes the programming a little easier. To communicate with the BT modules I am using AltSoftSerial which uses pin 8 and pin 9. The AltSoftSerial library can be downloaded from and it will need to be added before you can compile the example sketches.

Both BT modules are set with a communication baud rate of 9600. This can be changed but make sure you match the baud rate used when opening the software serial connection. // open software serial connection to the Bluetooth module. Begin ( 9600 ); Connecting the Bluetooth Modules Most HC-05s and HC-06s have 3.3v TX and RX pins. 5V Arduinos will read 3.3v as HIGH so the BT modules TX pin can be connected directly to the Arduino RX pin. However, the Arduino TX pin needs to be converted to 3.3v before connecting to the BT modules RX pin.

A simple way to do this is by using a voltage divider made from 2 resistors; I generally use 1 x 1K and 1 x 2K. Battle for middle earth 2 map pack download torrent Arduino RX (pin 8) to BT module TX pin Arduino TX (pin 9) to BT module RX pin via a voltage divider Both Arduinos have the same connections to the BT modules.

Arduino Delphi Serial Communication Arduino Bluetooth

Example 1: Remote Control an LED In the first example we get one Arduino to control an LED connected to a second Arduino. Communication is one way only and there is no error checking.

Arduino #1 simply sends the commands LEDON and LEDOFF to the Arduino #2. When the Arduino #2 gets the commands it sets the LED accordingly. Example 1: Circuit Arduino #1, the master device, just has the Bluetooth module. Arduino #2, the slave device we have the Bluetooth module and an LED (with a suitable resistor) on pin D3. Example 1: Sketches The Sketch on Arduino #1, the master device connected to the HC-05, simply sends the command LEDON, waits a second, sends the commands LEDOFF waits another second and then repeats indefinitely. Println ( ' ); BTserial. Println ( ' ); Using start and end markers allows the receiving device to check that it has a full command before acting upon it.

The Sketch on Arduino #2, the slave device, checks for data and if there is a start marker it starts to put the recieved data in to the variable receivedChars[ ]. When an end marker is received it sets the newData flag to TRUE. Any data not within the start and end markers is ignored. When newData is TRUE we know we have a command to process. In this case we set pin D3 HIGH or LOW to turn the LED on or off. Great tutorial! I haven’t messed with the Bluetooth modules much, but plan to soon as I have three hc-05 modules, and about to order three hc-06 modules to go with it.