Our aim is to bring you not just books written by experts on their subjects, but books written by experts at writing books. Our authors don't just repeat the documentation, they explore the subject matter. They go off the beaten track to find out how things works and make things happen. 

We also use programmers to proofread our books and we do our best to ensure the layout is sympathetic to programs. We try not to have a page break in the middle of a program so that you can read everything without having to move to a new page and forget what you have read. Of course, this isn't always possible and when a program has to be split we attempt to find a location that divides the listing at a point of meaning - e.g. try not to split a function or subroutine.

As layout is important, we prefer our paperback imprints - they are close to what we would like to read. Until recently we didn't  make ebook versions available because free flowing layout is not good for programming titles. Now that Kindle supports "Print Replica" format we do offer ebook versions. These aren't pure ebooks and they lack some features. In particular at the moment you can't read them on a Kindle only via Kindle Reader on mobiles, tablets, portables and desktop computers. The advantage is that you see pages formatted as in the paper book. We hope that Amazon improves the Print Replica format in the future to allow us to provide a fuller ebook support. 

Important Information:
All our Kindle edition are in Print Replica Format.
The reason for this is that we regard paging as essential for programming books however this means it only works on Fire Tablets and Kindle Reading Apps.
Check to see if your device is supported!

You can of course still read much of the content of our books on I Programmer and IoT-Programmer.

Please support our efforts by buying copies of our books and visiting the sites with ad-blocking off. We would like to encourage our authors to write more!

If you have any suggestions for titles contact us at: This email address is being protected from spambots. You need JavaScript enabled to view it.

 LATEST TITLES 

Raspberry Pi IoT in Python
 Using GPIO Zero
 2nd Edition 

 
GPIOZero2E180  

Raspberry Pi IoT in Python
With Linux Driver
2nd Edition 

Raspberry Pi IoT In C
Using Linux Drivers
2nd Edition

DriverPython2e180 DriverC2E180 

Extending & Embedding 
Python Using C

Raspberry Pi IoT In C,
3rd Edition
 

extendPython180 piciot3e180 

Master the Raspberry Pi Pico
in C:
WiFi with lwIP & mbedtls

Programming the ESP32
in MicroPython

picomaster180  esppython180 

Programming The
RaspberryPi Pico/W in C
Second Edition

Programming the
Raspberry Pi Pico/W
in MicroPython,
Second Edition 

 
picoC2E180 picopython2e180 

Programmer's Python:
Everything Is An Object,
Second Edition

Programmer’s Python:
Everything is Data

pythonObject2e180 pythondata180

The Trick Of The Mind

 

Programmer's Python:
Async

Trick180 pythonAsync180 

Programmer's Guide To Kotlin
Second Edition

Deep C# :
Dive Into Modern C#

 Page 24

 

Create a folder on the local machine to act as the top level project folder – all of your C projects will be stored in sub-folders of this one. Within your top-level folder, create a folder called .json and create a custom settings.json file. This contains the details of the remote machine and the folders you want to use on the remote:

change .json to:.vscode

Create a folder on the local machine to act as the top level project folder – all of your C projects will be stored in sub-folders of this one. Within your top-level folder, create a folder called .vscode if you need to, and create a custom settings.json file. This contains the details of the remote machine and the folders you want to use on the remote:

Page 132

 

The number of different duty cycles you can achieve depends on the number of clock pulses in the total period. At 10MHz there are just two clock pulses and so just four duty cycles 0%, 50% and 100%.

change four to three

The number of different duty cycles you can achieve depends on the number of clock pulses in the total period. At 10MHz there are just two clock pulses and so just three duty cycles 0%, 50% and 100%.

The table on this page should read:

PWM Frequency

Number of clock pulses

Number of different duty cycles

Resolution in bits

10MHz

2

3

1.6

5MHz

4

5

2.3

2.5MHz

8

9

3.2

1.25MHz

16

17

4.1

625kHz

32

33

5.0

312.5kHz

64

65

6.0

156.25kHz

128

129

7.0

nkHz

20000/n

20000/n - 1

Log2(20000/n -1)

In many applications 8-bit resolution for the duty cycle is considered the minimum acceptable and this sets the highest frequency to about 75kHz, which is high enough for most things.

For example, if you want to control a servo motor, see later, then you need a PWM signal with a frequency of 50Hz and at this frequency you can specify the duty cycle down to about 25 bits or around 40 million increments – more than enough for any real servo motor.

 

 

Page 148

The number of SPI buses a Raspberry Pi has depends on its model. The PiZero and Pi 3 have three SPI devices, but only SP0 and SP1 are available on the GPIO connector:

change SP0 and SP1 to SPI0 and SPI1 

The number of SPI buses a Raspberry Pi has depends on its model. The PiZero and Pi 3 have three SPI devices, but only SPI0 and SPI1 are available on the GPIO connector:

Page 153

First connect pin 19 to pin 20 using a jumper wire and start a new project. The program is very simple. First we check that the SPI bus is loaded:

change 20 to 21

First connect pin 19 to pin 21 using a jumper wire and start a new project. The program is very simple. First we check that the SPI bus is loaded:

Page 242

Change

struct sockaddr_nl sa;
sa.nl_family = AF_NETLINK;
sa.nl_pid = getpid();
sa.nl_groups = 0;

change sa.nl_pid = getpid();  to sa.nl_pid = 0;

struct sockaddr_nl sa;
sa.nl_family = AF_NETLINK;
sa.nl_pid = 0;
sa.nl_groups = 0;

WIthout this change the program doesn't work but returns no error

Page 248 (Same error as page 242)

Change

struct sockaddr_nl sa;
sa.nl_family = AF_NETLINK;
sa.nl_pid = getpid();
sa.nl_groups = 0;

change sa.nl_pid = getpid();  to sa.nl_pid = 0;

struct sockaddr_nl sa;
sa.nl_family = AF_NETLINK;
sa.nl_pid = 0;
sa.nl_groups = 0;

 

Page 187

I have only just discovered (I have never used a DHT11!) that the DHT11  is not 100% compatible with the DHT22. The DHT11 uses a different encoding for the data. The DHT22 uses 16 binary for each of the values but the DHT22 uses a first decimal byte followed by a fractional byte. This means that for the DHT11 the decoding is just to take the first byte as the integer part and the second byte as the fractional part - and no need to divide by 10.

Also it has been pointed out the the 1ms start pulse is too low for some devices - increase it to 20ms if the device ignores you.

Page 290

The number of SPI buses a Raspberry Pi has depends on its model. The PiZero and Pi 3 have three SPI devices, but only SP0 and SP1 are available on the GPIO connector:

change SP0 and SP1 to SPI0 and SPI1 

The number of SPI buses a Raspberry Pi has depends on its model. The PiZero and Pi 3 have three SPI devices, but only SPI0 and SPI1 are available on the GPIO connector:

 

Page 298

First connect pin 19 to pin 20 using a jumper wire and start a new NetBeans project. The program is very simple. First we initialize the library and the SPI bus:

change 20 to 21

First connect pin 19 to pin 21 using a jumper wire and start a new NetBeans project. The program is very simple. First we initialize the library and the SPI bus:

Update: 3 March 2020

NetBeans 8.2 seems to have stopped working under Raspian (Buster). It installs but wont open a new project. It still works under Windows 10. 

As NetBeans 11.2 works perfectly on the Pi there is no reason to continue to try and make the unsuported version work. Follow the instructions to install it on the Pi given below. 

The NetBeans 8.2 plugin library is include but you have to enable it. Make sure you click the check for newest buttons after enabling it.

Select the C++ plugin and install it. 

After this you can run NetBeans - the script in the bin directory - as usual.

I understand the the Apache team are working on native support for C/C++ but it probably wont be complete until version 12 some time this year.

Original Information

NetBeans has been moved to Apache and Oracle are slowly moving the source code of the project to its new home. At the moment they haven't made the C/C++ code available but the old plug in works. What this means is that you have two choices. However before this you need to make sure you have a JDK installed:

NetBeans is a Java program that will work on any machine that supports a Java Virtual Machine (JVM) and the Pi comes with a JVM already installed as part of Raspbian. If you are installing NetBeans on a PC or a Mac you need to check that Java is installed and if it isn't you need to install it.

To check open a command prompt, this works for Windows, Linux and Mac OSX, and type:

java -version

If you don't see a listing something like:

openjdk version "11.0.3" 2019-04-16 LTS
OpenJDK Runtime Environment Corretto-11.0.3.7.1 (build 11.0.3+7-LTS)
OpenJDK 64-Bit Server VM Corretto-11.0.3.7.1 
                               (build 11.0.3+7-LTS, mixed mode)

then either Java isn't installed or it is miss configured. Consult the documentation on the website of the JDK you are using. You can use any JDK from 9 though 12.

If you haven't got Java working there is no point moving on to install NetBeans as it simply will not work.

  • You can stay with NetBeans 8.x and use the original Oracle downloads and installers. This makes it very easy to install and it all works exactly as described in the book. There is no particular disadvantage of this approach as there is nothing in NetBeans 11 that you need to work with C/C++.

You can find the 8.x series of NetBeans by following the Older releases link on the Apache download page.

It is currently here but given the changes occurring it could well change and you might need to visit what ever the current download page is.

A direct link to NetBeans 8.2 can be used but it might change - if so check out the new main download page.

As described in the book download the C/C++ version or the complete version.

 

  • The second option is to download and install the latest version of NetBeans - 11.x at the time of writing. 

If you do this it doesn't have the C/C++ option included and you have to set it up so that it makes use of the 8.2 plugin.  

The procedure described below works for Raspian, Linux, Windows or OSX.

Go to the NetBeans web site https://netbeans.apache.org and navigate to the download page. Select the latest version and download the zip listed as "Binaries". Its name should be something like:

netbeans-11.1-bin.zip 

according to the version number. You will also see installers for various operating systems at the time of writing there isn't an installer for Raspian and the other installers often fail to find the installed JDK - working with the binary is just as easy.

After the download is complete you have to extract the files in the zip to a suitable directory. If you are the only person going to use NetBeans then your Linux home directory or Program Files under Windows is suitable. Extract all of the files into the directory.

Navigate to the directory and then netbeans/bin and run the file netbeans for a Linux installation or netbeans.exe or netbeans64.exe for a 32 or 64 bit Windows installation. These small programs install NetBeans and subsequently runs the IDE after installation. Run it in a terminal, accept the license agreement and wait while it installs.

At this point you will have a working NetBeans IDE and you can use it to create Java, PHP and JavaScript programs but, at the time of writing the C/C++ plugin is not installed and an upgraded version isn't available. As a temporary solution you have to use the original 8.2 plugin - this is likely to change as the NetBeans project develops.

All you have to do is use the Tools | Plugins menu option and, in the Settings tab of the dialog box that appears enable the NetBeans IDE 8.2 update center. If it isn't in the list for any reason add:

http://updates.netbeans.org/netbeans/updates/8.2/uc/final/distribution/catalog.xml.gz

Next go to the Available Plugins tab and click the Newest button to update the list. It is also worth selecting the Updates tab and click the Check For Updates tab to make sure everything is up-to-date before installing the plugin. Search for or find the C/C++ plugin, select it and click the install button. Follow the installers instruction and allow it to install and upgrade everything it wants to.

 

If installation fails make sure you have all of the other plugins up-to-date and try again or check to see if it works after up-date.

If you are using NetBeans under Raspian you can add it to the Programming group in the menu. All you have to do is select Preferences, Main Menu Editor. Then select the Programming group and select New Item. Fill in the dialog that appears as shown:

 

The command is:

/home/pi/netbeans/bin/netbeans 

adjusted to reference your home directory rather than that of user pi if necessary. After this you can run NetBeans from the menu. If you want to add an icon then simply right click on the menu item, select properties and click on the default icon. Next simply navigate to /home/pi/netbeans/nb/ and select netbeans.icon.

If you are using NetBeans on a Pi then you can now create a new C/C++ project as described in a later section. If you are using NetBeans on a deskopt machine you now need to setup a remote connection to a Pi to work with C/C++.