Sunday, August 26, 2018

Arduino Remote Controlled Car – Part 1


For my vacation , I decided to build a remote-controlled car.  In the next few posts, I will detail how I made the car and what parts were used.  I will also share the code and show how everything is wired and works together.

For this car, I deciced that I was going to 3D print the entire body and remote therefore the first thing I had to do was to design and print the parts.  For this I found several things on thingiverse where I used a few of the parts as is but most of them I made modifications to.  I also created a number of the parts myself. If you would like to print the car/remote yourself, you can find the STL files for all of the parts here:  https://www.thingiverse.com/thing:3067342

The following video shows the car in action:


If you are going to be following along and building the car as we document it here, you should start off by printing the joystick_base.stl and the Arduino_joystick_stand.stl files. You will want to print these files first because we will start off configuring the Bluetooth modules and getting the Arduino used for the remote control communicating with the Arduino used by the car.  For this first post you will need the following parts:

2 Joystick breakout modules (Link is for a ten pack, only by one ten  pack)
2 Prototyping shields (Link is for a five pack, only by one five pack)
2 Portable phone charger batteries The link is not to the exact one that I use because they are no longer available but the one in the link are the similar physical size.



The following Fritzing diagram shows how to wire the two Bluetooth modules and the two joystick modules to the Arduino.  One note, we do not need a common ground between the two Arduinos because they will be two separate circuits.  One circuit for the remote and one circuit for the car.




The first thing we need to do is to configure the two Bluetooth modules, so they will automatically connect and begin communicating.  To do this we will need to create a small Arduino project that will allow us to configure the modules using the serial monitor in the Arduino IDE. Let’s look at the code for this.

This code will start off by including the Arduino SoftwareSerial library and creating an instance of the SoftwareSerial type.  The following code shows how to do this.

  #include <SoftwareSerial.h>
  SoftwareSerial HC05(10, 11); 
  bool addNewLine = false; 


The first line includes the SoftwareSerial library and the second line creates an instance of the type.  The Boolean variable in the last line will be used to tell the application when to add a new line in the serial console to make the output easier to read.  

Now we need to add code to the setup() function that will configure the serial console and the SoftwareSerial instance.  The following code shows the setup() function for this project.

  void setup()  {    
    Serial.begin(9600);    
    pinMode(9,OUTPUT);    
    digitalWrite(9,HIGH);    
    HC05.begin(38400);       
    Serial.println("Connected to HC-05.  Try connecting from any device or issue AT commands");  
  } 


This code starts off by setting up the serial console with a baud rate of 9600 and then defines that the digital 9 pin will be an output pin and set it to high.  The digital 9 pin is connected to the key pin on the HC-05 Bluetooth module.  We pull this pin high to enable the Bluetooth module.  We then configure the HC05 instance of the SoftwareSerial type with a baud rate of 38400 and print a message to the serial console letting the user know that everything is configured and ready to go.  You will note, in this first project we set the baud rate of the SoftwareSerial instance to 38400 because we are configuring the Bluetooth module.  Once the Bluetooth module is configured we set the baud rate to 9600 when we are sending/receiving data.

In the loop() function we will take any input from the Bluetooth module and print it to the serial console and any input from the serial console we will send to the Bluetooth module.  The following code will do this.

  void loop()  {    
    if (HC05.available()) {      
      if (addNewLine) {        
        Serial.write("\r\n");        
        addNewLine = false;      
      }      
      Serial.write(HC05.read());    
    }      
    if (Serial.available()) {      
      HC05.write(Serial.read());      
      addNewLine = true;    
    }  
  }


In this function the first thing we do is to see if there is any data available from the HC05 SoftwareSerial instance (the Bluetooth module) by using the available() function.  If there is data available, we check to see if we need to add a new line to the serial console by checking the addNewLine Boolean variable.  If we need to add a new line, we write a carriage return and line feed to the serial console and then set the addNewLine Boolean variable to false.  Finally we write the data that was received from the Bluetooth module to the serial console.

Next, we check to see if there is any data available from the serial console, also using the available() function and if so we write that data to the Bluetooth module.  We also set the addNewLine Boolean variable to true, so the next time data is received from the connected device, we will add a carriage return and line feed to the serial console.

Before we plug the Arduino in and run this code, we will need to set the HC-05 Bluetooth module into configuration mode.  To do this we will need to press and hold the button on the Bluetooth module and then plug the Arduino into the computer giving power to the Bluetooth module.  In just a couple of seconds the light on the Bluetooth module will start to blink very slowly where the light will be on for two seconds and then turn off for two seconds.  Once the light starts to blink, we can release the button and Bluetooth module is ready to be configured.  

To configure the Bluetooth module, we issue AT commands.  To send an AT command, you would use the following format:
  
  Set item: AT+{command}{new setting}  
  Query item: AT+{command}?

To set an item we type in the letters AT followed by the plus sign, the command and the new setting without any spaces.  For example, to set the role of the Bluetooth module to a slave role we would issue the following command (note: AT commands are case insensitive):
at+role0
To query the item, we would type in the letters AT followed by the plus sign, the command and then a question mark.  For example, to query the role of the Bluetooth module we would use the following command:
at+role?
To issue the command we type the command into the input box on the serial console and press enter.  We will need to set the serial console to add both a NL (new line) and a CR (carriage return).  The following image shows how to issue a AT command:



After we type in the at+role? Command we press the enter key or the send button to send the command to the Bluetooth module.  The Bluetooth module will respond with the results of the query as shown in the following image:



Let’s go ahead and configure one of the Bluetooth modules as the master and one as the slave.  It does not matter which is the master or which is the slave because either device can stream data to the other device.

Let’s start off by configuring the slave device.  To do this connect one of the Arduinos to the computer, run the application that we wrote at the beginning of this post and then run through the command that we will outline in the next few paragraphs.

The first thing we will want to do is to issue the test “AT” command to the Bluetooth module.  The module should respond back with an “OK” message.  If you do not get a response back, check to make sure that the serial console is configured to send both the NL & CR (new line and carriage return).  If you receive an error response, try issuing the “AT” command again. 

Once we are sure that the serial monitor, and the Bluetooth module are talking, we will want to see what the UART settings are currently set to for this module.  To do this send the “AT+UART?” command.  For the examples in these next few posts we are going to assume that the UART settings are 9600 Baud, 0 stop bits and 0 parity.  If this is not how your module is configured then issue the following command “AT+UART=9600,0,0”.

The next thing we want to do is to set the role of the device to a slave role.  To do this we issue the following command “AT+ROLE=0”.  Finally, we will want to retrieve the address of this Bluetooth module. The following command will retrieve the address “AT+ADDR?”.  Make sure the address is written down, because we will be using it when we configure the master device.
The commands that we ran to configure the slave module are:

Command
Response
AT
OK
AT+UART?
+UART:9600,0,0 (if not set it to this)
AT+ROLE=0
OK
AT+ADDR?
+ADDR:{address}

Now let’s configure the master.  To do this connect the other Arduino to the computer (remember to press and hold the button as you power up the module), run the code we wrote at the beginning of this section and issue the commands that we will go through in the next few paragraphs.  

As with the slave device, the first thing we will want to do is to issue the “AT” command to the Bluetooth module.  The module should respond back with an “OK” message. If you do not get a response back, check to make sure that the serial console is configured to send both the NL & CR (new line and carriage return).  If you receive an error response, try issuing the “AT” command again. 

Now we will want to see what the UART settings are for the module.  To do this send the “AT+UART?” command.  We will want to configure the UART settings to 9600 Baud, 0 stop bits and 0 parity.  If this is not how your module is configured then issue the following command “AT+UART=9600,0,0”.

The next thing we want to do is to set the role of the device to a master role.  To do this we issue the following command “AT+ROLE=1”.  Now we will want to set the connection mode to connect to a fixed address (mode 0).  To do this issue the following command “AT+CMODE=0”.  Since we are telling the Bluetooth module to connect to a fixed address, we need to give it the address of the slave device we need it to connect too. To do this issue the following command “AT+BIND=????,??,??????” where the question marks are the address of the slave device.  

When we queried the address of the slave device the address was returned separated with colons like this “98d3:31:300e42”. When entering the address in the bind command the address needs to be separated by commas like this “98d3,31,300e42”.

The commands that we used to configure the master device are:

Command
Response
AT
OK
AT+UART?
+UART:9600,0,0 (if not set it to this)
AT+ROLE=1
OK
AT+CMODE=0
OK
AT+BIND=????,??,?????? (question marks are the addr of the slave devie)
OK

Now if we reset both devices by recycling the power the two Bluetooth modules should connect.  Start off by recycling the power on the slave device and you will see the LED blinking rapidly.  Then recycle the power on the master and once the two devices connect the LED on both devices will blink rapidly twice, then turn off for two seconds and then repeat. This light sequence indicates that the two devices are connected.  Now that we have the two Bluetooth modules connected, we will need to stream the joystick data from the Arduino that are connected to the joysticks to the other one.  We will start off by defining the protocol that we will use when streaming the data.

When we are streaming data, or sending large amounts of variable length data, we need some way to tell the receiving device where a new message starts and where it ends.  Luckily for us, there are built in ASCII codes that allow for this.  The 0x01 SOH (Start of Heading) and the 0x04 EOT (End of Transmission) codes can be used to tell the receiving device when a message starts and when it ends.  For our remote-controlled car, the protocol that we will define is when the receiving device receives an 0x01 ASCII character, it will know that a new message has begun.  When it receives an 0x04 ASCII character, it will know that the message has ended.  Everything between the 0x01 and the 0x04 characters are the message itself.  

The message itself will contain two bytes of data, one that indicates the vertical position of the left joystick and one that indicates the vertical position of the right joystick.  Therefore, a complete transmission will contain a total of four bytes likes this:

  0x01 ßStart of header
  0xDD ßvertical position left (221 decimal)
  0xDD ßvertical position right (221 decimal)
  0x04 ßEnd of transmission


Now that we have the protocol that will be used to transmit the joystick position from one Arduino to the other, let’s begin by writing the code that will run on the Arduino that the joystick breakout modules is connected to.  
The position of the joystick is read through the two analog pins that are connected to it. The first thing we will need to do in the code is to include the SoftwareSerial library for the Bluetooth module, create an instance of the SoftwareSerial type and define the pins that the joystick module is connected to.  The following code will do this:

  #include <SoftwareSerial.h>

  #define BT_PIN 9 // digital pin Bluetooth
  #define LEFT_VER_PIN 1 // analog pin 
  #define RIGHT_VER_PIN 3 // analog pin 

  
  SoftwareSerial HC05(10, 11); 

In the setup() function we will need bring the BT_PIN high and initialize both the serial console and the instance of the SoftwareSerial instance. We initialize the serial console in all examples in case we need to log anything for debugging.  The example code does not use it but it is there if you need it.  Here is the code for the setup() function:

  void setup() {    
    pinMode(BT_PIN,OUTPUT);      //Set Mode BT_PIN     
    digitalWrite(BT_PIN,HIGH);   //Set BT_PIN high    
    HC05.begin(9600);            //Initialize the SoftwareSerial instance    
    Serial.begin(9600);          //Initialize serial console        
    Serial.println("Connected to HC05.");  
  }

In our loop() function we will need to read the vertical positions of both joysticks and then write the message to the Bluetooth module.  The following code will do this:

  void loop() {    
    int left_ver_pos = analogRead(LEFT_VER_PIN) / 4;    
    int right_ver_pos = analogRead(RIGHT_VER_PIN) / 4;     
    HC05.write(0x01);    
    HC05.write(left_ver_pos);    
    HC05.write(right_ver_pos);    
    HC05.write(0x04);    
    delay(50);  
  }


In this code we read the vertical position for both the left and right joysticks.  We then use the HC05 instance of the SoftwareSerial type to write the data to the Bluetooth module.  A short delay was added at the end of the function before we loop back and start over.  

The Arduino analog pins have a range from 0 to 1023 however we want to limit the positional information, that we transmit, to a single byte which can have a range from 0 to 255 therefore when we read the vertical position of the joysticks we divide the number by 4 so the vertical position will be within the size of a single byte.

Now that we have the code that will run on the Arduino that the joystick is connected to, we need to write the code that will run on the Arduino that will receive the data.  This code will need to start off by including the SoftwareSerial library for the Bluetooth module and create an instance of the SoftwareSerial type.  We will also need to define a buffer that will be used to store the data as it comes in through the Bluetooth module.  The following code will do this:

  #include <SoftwareSerial.h>  
  #define MAXBUF 16  
  #define BT_PIN 8
  
  SoftwareSerial HC05(12, 13);   
  byte buf[MAXBUF];

This code starts off by including the SoftwareSerial library and then defines the max size for the input buffer which is 16. While we could limit the size of the buffer to four because we know that each message will be four bytes in size, we always want to have extra space in the buffer, especially with wireless communication, in case the message gets messed up in transmission.  

In the setup() function we will initialize the serial console and the SoftwareSerial instance.  We will also need to pull the key pin for that Bluetooth module high. The following code does this:

  void setup()  {    
    Serial.begin(9600);    
    pinMode(BT_PIN,OUTPUT);    
    digitalWrite(BT_PIN,HIGH);    
    HC05.begin(9600);    
    Serial.println("Connected to HC05");   
  }


Now in the loop() function we will want to continuously read the input from the Bluetooth module until we receive and End of Transmission (0x04) byte.  As we read the data in, it will be stored in the byte array and once the 0x04 byte is read in we will print out the message and then loop back. Here is the code for the loop() function:

  void loop()  {    
    memset(buf, 0, MAXBUF);    
    int counter = 0;    
    while (counter < MAXBUF) {      
      if (HC05.available()) {        
        byte val = HC05.read();        
        buf[counter] = val;        
        counter++;        
        if (val == 0x04) {          
          break;        
        }      
      }
    
    }    
    for(int i=0; i<counter; i++) {      
      Serial.print(buf[i]);      
      Serial.print(" ");    
    }    
    Serial.println(" ");   
  }


This function starts off by using the memset() function to initialize the buffer with all zeros.  We then create an integer variable that will count how many bytes are read in.

A while loop is used to continuously loop until the maximum number of bytes have been read.  Within the while loop we use the available() function from the HC05 SoftwareSerial instance to see if there is any values to read from the Bluetooth module.  If there is a value to read, we use the read() function to read the value in, store it in the buf byte array and increments the counter.  We then check to see if the value that was read in is equal to 0x04 and if so we use the break statement to break out of the while loop.

Finally we create a for loop that will loop through the values in the buffer and print them to the serial console.  If we execute the code on both Arduinos and move the joystick around, we will see output similar to the following screen shot:




As we can see from the output, each message starts with the 0x01 byte and ends with the 0x04 byte.  In between these two bytes is the joysticks positions of the vertical axis.

We know that the packets are supposed to be four bytes in length, in a production environment we would want to toss out any messages that were not four bytes in length because we know that if the message is not four bytes in length then the message got messed up in transmission.  

Now that we are able to transmit data between the two Arduino’s we need to build the remote with the joystick_base and the Arduino_joystick_stand.  The remote should look like the following image where we use one of the prototype shields to connect the Bluetooth and joystick modules to the Arduino.  The portable phone battery, used to power the Arduino, should be able to rest behind the joystick base to make the remote easy to hold.




In the next post we will begin building the car’s body and add the motors to the remote-controlled car.  If you are building the car as you are reading these posts, you may want to begin printing the pieces for the car because it will take a few days to print. 

In my new book, Mastering Arduino , which will be released in September of 2018, I dedicate a chapter to Bluetooth Classic and the HC-05 Bluetooth module.  In this chapter we take an in depth look at Bluetooth Classic and how the HC-05 works. We also look at all of the different configuration options for the Bluetooth module explain why I prefer Bluetooth classic, for streaming data, over Bluetooth LE.   

Monday, April 3, 2017

Monoprice Maker Select Ultimate 3D printer


About a year and a half ago I purchased my first 3D printer which was the original Monoprice Maker Select 3Dprinter (Monoprice has release version 2 of this printer now). This printer was an outstanding printer for a beginner and I was really impressed with how easy it was to setup and use.  After using this printer for several months, I purchased another printer from a different manufacture however I did not have the best of luck with it.  When I finally gave up on making that printer work decently, I decided to go back to Monoprice for my third printer.  I ended up purchasing the Maker Select Ultimate 3D printer and after using this printer for several months, I can honestly say that I am very happy with my decision.

The Maker Select Ultimate is a rebadge of the Wanhao Duplicator 6. It seems like the only difference between the two printers is the Wanhao Duplicator 6 comes with an acrylic cover while the Monoprice Maker Select Ultimate does not however I have not used a Duplicator 6 so I cannot say for sure.

The first thing I noticed about the Maker Select Ultimate was how easy it was to unpack and setup.  I was printing within 30 minutes after receiving the printer.  All I needed to do was to cut and remove the packing material, remove the accessory boxes and install the filament spool holder.  I have read other reviews that say the spool holder was too small for their filament spools however I use Hatchbox filament and I have found the filament spool holder works great.

The second thing I noticed was how quite the printer is.  I have always had my 3D printers in my loft and the previous two printers were so noisy that we had a hard time watching TV in our living room while I was printing something.  With the Maker Select Ultimate, I do not have this issue however this has not always been the case.  The first two Maker Select Ultimate printers that I received had very noisy fans (I will talk about why I had two previous Maker Select Ultimate printers later in this review) however this third printer is incredible quiet.  In fact, the fans are so quiet, I can barely hear them.  

The specs for the Maker Select Ultimate says it can print up to 150mm/sec.  I have my Cura setup with a general speed of 125 mm/sec and I have had excellent prints with that speed.  I am using Cura 2.3.1 and have made several tweaks to the various speeds.  The following image shows my current printing speeds:



The first Maker Select Ultimate printer that I received shipped with a default acceleration of 800mm/sec2.  This was way to slow and other reviews have recommended that you change this within the firmware.  I would recommend, instead of adjusting the firmware, adjusting this setting within Cura.  By adjusting this within Cura you can adjust it for each print if you want too.  The latest version of the Maker Select Ultimate now has the default acceleration set to 4000mm/sec2 which greatly increases the print speed. 

The build volume is good with a 200 X 200 X 175 mm build area. Personally, I have only used PLA filament but the heated bed means you can use most filament types.  Leveling the print bed is also relatively painless because the printer walks you through the whole process.  The first Maker Select Ultimate printer that I received I did have to re-level the bed after every third or fourth print however with the new printer I have only had to level the bed once since the initial leveling and this has covered over 20 prints.

The specifications say that the Maker Select Ultimate can print with an ultra-high resolution of
20 microns.  Printing at this resolution gives incredible prints however it does take a while to print anything at that resolution.  The image to the left was printed at 100 microns and took 32 minutes while the image to the right was printed at 20 microns and took 145 minutes.  Both were printed with the same silver filament using the print speeds shown earlier with a raft.







It is very easy to change the filament with Maker Select Ultimate printer. By selecting the change material option, the printer will heat up the hot end, eject the filament and then tell you to put in the new material.  You will want to use the white tubbing that comes with the printer to protect the hole that the filament is inserted into.  The hole on the first Maker Select Ultimate printer that I received was deformed within two weeks by the filament rubbing against the edge of the hole.  You will want to cut a small piece of tubbing off and insert it in the hole as shown in the following image.



Another nice feature with this printer is the ability to change settings while you are printing.  You can increase/decrease the print speed, extruder temperature, build plate temperature, fan speed, material flow and retraction rate.  

Everything isn’t perfect with the printer.  The one thing that I really do not like is what is displayed when the printer is printing.  Rather than giving you the completion percentage and the x/y/z position, the display has a bar showing print progress and gives you an estimated time to completion which is normally not very accurate since it is based on the average print time per layer.  Unless you are printing a solid cube the time it takes to print each layer can vary significantly.

As I mentioned earlier this is my third Maker Select Ultimate printer.  The first two printers that I received had problems with the hot end thermostat.  To be up front, I use my 3D printers a lot.  The first printer I had lasted 28 days with around 200 print hours. When I tried to print anything, it would display an error indicating it had problems reading the hot end thermostat and would not let me print anything.  Not sure what was wrong but I suspect it was something with the main board because I did not see anything wrong with the wires or the thermostat itself.  The second printer I had lasted 35 days with around 250 print hours.  This time the wire coming out of the hot end for the thermostat broke.  In the following image you can see how it broke.
                                                                                                                            


This next image shows how the wires are supposed to look



The wires are held together with wire ties and I believe the wire to the thermostat wiggled lose and dangled down a little too low and got caught on my print which caused the wire to snap.  I suspect this because of the sound the printer made just before it stopped working.  For the third printer, I used some tape to hold the cables up higher as shown in the following image.



You may think with the problems I had with the first two printers that I would not recommend this printer however the customer support at Monoprice was so outstanding that I comfortable recommend this product to anyone looking for a good 3D printer.  Both times that I had issues with the printer I contacted Monoprice via the online chat and had RMA numbers with 20 minutes.  The first printer was shipped out hours after Monoprice received my printer back.  The second time I had to send the printer back it was on back order so it took almost two weeks to get a new one but I was fine with that because it appears Monoprice has made a lot of improvements to this new printer.

Whenever you purchase items like a 3D printer when it is first released, you need to expect issues and good manufactures make minor adjustments to the products based on the feedback they received.  It appears to me that Monoprice has listened to the feedback of users and made excellent adjustments.  The fans being much quieter and having a higher default acceleration speed were excellent improvements.

If I had to rate the printer using the standard 5 star system, I would give it 4.5 stars.  With how great Monoprice’s customer support was, and seeing the improvements made in this latest model I am overlooking the problems I had with the first two printers with this rating. 

My only two complaints with the current printer is what is being displayed while the printer is printing and I wish it came with an acrylic cover like the Duplicator 6 especially since all the holes needed to install the cover are already drilled in the frame.  Overall I would definitely recommend Monoprice Maker Select Ultimate printer for both the new and experience users.  If the Maker Select Ultimate is out of your price range then I would recommend looking at the Monoprice Maker Select 3Dprinter.  

Wednesday, January 4, 2017

Mastering Swift 3 for Linux

My new book, Mastering Swift 3 for Linux has just been released.  While most books on Swift are written to introduce the language using Apple’s development tools, this book is written for the developer that wants to use Swift on the Linux platform. 

I have always thought that a developer cannot master a programming language without a good understanding of the basics.  With that philosophy in mind this book starts with the basics of the Swift language before moving into more advance features and concepts. The first five chapters will introduce the Swift programming language and will give the reader a good understanding of the Swift programming language.  The second half of the book will cover more advance topics such as concurrency, network development, using C libraries with Swift and memory management including strong reference cycles.

This book also has a chapter dedicated to using Swift on Single-Board Computers.  The first half of this chapter will show the reader how they can use Swift to interact with external devices like LEDs, buttons and temperature sensors. The second half of the chapters shows the reader how they can build and program an autonomous robot using Swift and the BeagleBone Black.

Here is a description of what is covered in each chapter of the book:

Chapter 1Taking the First Steps with Swift, gives a brief introduction to the Swift language. It also covers the basic Swift language syntax and discuss proper language styles.
Chapter 2Learning About Variables, Constants, Strings, and Operators, will show how to use variables and constants in Swift. It will also discuss the various data types and how to use operators in Swift.
Chapter 3Using Swift Collections and the Tuple Type, will look at how we can use the Swift collection types to store related data. These collection types are the array, set and dictionay types. 
Chapter 4Control Flow and Functions, will cover control flow and functions in Swift. It is essential to understand the concepts in this chapter before going on. Every application that we write, beyond the simple Hello World applications, will rely very heavily on the control flow statements and functions.
Chapter 5Classes and Structures, will look at what makes Class and Structures similar and what makes them different. We'll also look at access controls and object-oriented design. The chapter also covers memory management in Swift.
Chapter 6Using Protocols and Protocol Extensions, will cover both protocols and protocol extensions in detail since protocols are very important to the Swift language, and having a solid understanding of them will help us write flexible and reusable code.
Chapter 7Protocol-Oriented Design, will cover the best practices of Protocol-Oriented Design with Swift. It will be a brief overview of what is covered in my Swift 3 Protocol-Oriented Programming (POP) book.
Chapter 8Writing Safer Code with Error Handling, will look at Swift’s error- handling features. While we are not required to use this feature in our custom types, it does give us a uniform manner to handle and respond to the error. 
Chapter 9Custom Subscripting, will discuss how we can use custom subscripts in our classes, structures, and enumerations. Subscripts in Swift can be used to access elements in a collection. We can also define custom subscripts for our classes, structures, and enumerations.
Chapter 10Using Optional Types, will explain what optional types are and the various ways to unwrap them. For a developer who is just learning Swift, optional types can be one of the most confusing items to learn.
Chapter 11Working with Generics, will explain how Swift implements generics. Generics allow us to write very flexible and reusable code that avoids duplication.
Chapter 12Working with Closures, will teach us how to define and use closures in our code. Closures in Swift are similar to blocks in Objective-C except that they have a much cleaner and easier way of using syntax. This chapter concludes with a section on how to avoid strong reference cycles.
Chapter 13Using C Libraries with Swift, will explain how we can link and use standard C libraries with our Swift applications.  This gives Swift developers access to all the same libraries that Linux C developers have access too.  Knowing how to use C libraries with Swift is essential for any developer that wants to develop Linux apps with Swift
Chapter 14Concurrency and Parallelism in Swift, will show how to use Grand Central Dispatch to add concurrency and parallelism to our applications. Understanding and knowing how to add concurrency and parallelism to our apps can significantly enhance the user experience.
Chapter 15Swift's Core Libraries, will be a chapter on using the Swift core libraries, including reading/writing files, network primitives, and JSON parsing.
Chapter 16, Swift on single-board computers, will show how we can use Swift for IoT and robotic projects using a single-board computer.  This chapter will feature the BeagleBone Black and the Swifty Bones library.
Chapter 17Swift Formatting and Style Guide, will define a style guide for the Swift language that can be used as a template for enterprise developers who need to create a style guide, since most enterprises have style guides for the various languages that they develop in.
Chapter 18Adopting Design Patterns in Swift, will show you how to implement some of the more common design patterns in Swift. A design pattern identifies a common software development problem and provides a strategy for dealing with it.


This book is written in an example-based approach where each topic covered is backed by examples which are designed to reinforce the topic covered and show how to implement it within the reader's own code. 

You can purchase the book from Amazon.