Wednesday, 20 December 2017

Raspberry Pi User Group Meeting - November 19, 2017

We have a few core people who show to our meetings at the New Glasgow Library. This meeting was no different that way.

What was new was the free Stepped Tone Generator / APC kit we have to offer. The Stepped Tone Generator is actually a circuit taken from "Engineer's Mini Notebook, Vol.1 - Timer, Op Amp & Optoelectronic Circuits & Projects," by Forrest Mims III. APC or Atari Punk Console is the name that was given to the circuit by some electronics designer who made it their own. The circuit's sound is pretty lo-fi so imagine something that might come from an old 80's video game, thus the APC name. The circuit's central component is the 555 timer. I am writing another post with this circuit so you can also reference that post as well.

We built one of the kits that I had to make sure all the components worked and they did. I also had another circuit of the same that I had made before and had taken to the meeting. We tried to get it to work but found it did not. Well, ... time to troubleshoot.

Stepped Tone Generator / APC Schematic:


Anytime something does not work in your electronics projects is an opportunity to learn and to practice. Now, it had been sometime since I had to troubleshoot anything past something like a misplaced power supply lead to one of my circuits. It took a little time to figure out what was wrong. Even then, it was only after we had fixed the circuit had I realized what must have been wrong.

We started out checking all the wires to see if any were missing or misplaced. Then we started using the DMM (digital multi-meter). We swapped speakers and even IC's. While using the DMM it was seen that the voltage level on the middle lead one of the pots was not as it should be.

We are using the square blue trimpots for the kits because they are 1) more convenient to use in solderless breadboards and 2) they cost a lot less per item. To use a metal potentiometer would require at least leads soldered on to the lugs and then, if it were not mounted on something, it would hang free, useable but subject to disconnecting easily. Below are some examples of trimpots. Note that one is on its side and how that relates to the problem I found as described below.

The point is that little blue trimpots can look like they are correctly inserted into a solderless breadboard when they are not. Without really realizing what was wrong with the pot, it was removed, reinserted into an unused portion of the solderless breadboard and leads inserted into appropriate holes to allow DMM leads to take measurements. The pot was fine. It was reinserted into the circuit and presto, the circuit worked.

After the meeting, I realized that yes, the problem was with the potentiometer. It must have been inserted sideways so that two of the leads were connected and the third lead connected to the rest of the circuit to follow. However, the lead that was supposed to be connected to the power rail was not. So no power was supplied to the variable voltage divider found on the left side of the schematic.

Wednesday, 13 December 2017

A Beginner's Journey into DIY Synthesis

Hi. If you have found this blog, surprise! You have stumbled upon a pretty new blog on DIY synthesis, for music, not for another field of electronics such as Ham Radio.

My name is Bruce and I have been building occasional projects in electronics for a number of years. Lately, I would like to have a general focus on music. Music is another hobby of mine. I play guitars and have a Casio XW-G1 synthesizer. Patchblocks are another type of synthesizer that I have recently started exploring. The room to move with this platform is so great and not a bad way to learn about how synthesis modules are put together. Patchblocks software is free to try out. Just stick with learning the tutorials found in the IDE and you will make some interesting sounds. There are also a number of ready-to-go patches before you even learn how to program. Really cool stuff.

One thing I have found over the years is that after playing a musical instrument, I began appreciating other genres of music. Originally, I like rock, classic rock and alternative. Learning how to play harmonica (my first choice in musical instruments) and then guitar, really opened up my horizons. I started to listen to more country and folk music. I appreciate some electronic music, some bluegrass, a little more metal, more classical and some that I find hard to pin down.

To bring this rambling back to DIY synthesis, I will purport that one type or area of electronic synthesis is superior over another, at least not yet. I know that some synthesizers sound better than others and there are many that are classics. What is comes down to some of the time is that you buy, use, and make what you can afford. Budget it whatever way you like so if you really want to stick with only exploring analog circuits, save for a bit and buy what you need. I like to explore a lot of different areas of electronics so I have Arduino's, PIC IC's, Basic Stamp II's, LM324's, 555 and 556 Timer IC's, as well as a number of other components.

Books tend to be a great resource for me. I have some electronic engineering technician textbooks, some hobby electronics books that cover a wide range of topics and lots of other books. Programming languages are also great. I have experimented with C, Arduino C, C++, BASIC, and Python. Processing is another environment that I have dabbled in and think has great potential for me. Just look at the Processing Exhibition page and you see lots of different project ranging from physical interaction to data collection and representation.

In the blog entries to come, do not be surprised to see one area covered such as oscillators made from analog circuits and then others made from digital IC's. I hope to have some interested readers so drop a line if you like. Let me know what you think.

Sunday, 22 October 2017

Raspberry Pi User Group Meeting (RPUG) - October 15, 2017

Our last meeting at the New Glasgow Library was pretty low key. We are looking at putting together some workshops on basic and some not-so-basic topics.

I really want to make a simple project - a Four Op Amp Function Generator. Forrest Mims provides a schematic in his first Engineer's notebook. You can find all kinds of examples of schematics online. One of the nice things is that it can fit on a single solderless breadboard. There are even IC's that come in packages containing 4 op amps although any op amp should work. I plan on using an LM324. They are on order.

I have some other IC's of op amps, actually some NTE947's for which I used the pinout to redraw the schematic. One of the nice things of drawing schematics using IC's is that you can often just use the old schematic and change the pin numbers specified by the new IC. If you have ever tried to draw a schematic using the pinout of an IC, you will quickly realize that there is an art to the whole thing.

Look for a workshop coming soon.

... by the way, I am also taking a ham radio course with the local amateur radio club, Pictou County Amateur Radio Club.

Here is their link:
Pictou County Amateur Radio Club,

Saturday, 21 October 2017

ESP8266 / nodeMCU and DHT11

October 21, 2017

This will be a short post. This will have a date on it, I am sure. But, I am posting material that will likely become dated soon, so I want that in the text of the post as well.

The ESP8266 IC is a great boon to the electronics hobbyist. I have been using a nodeMCU version lately and have had some good amount of success although there has been a lot of digging to get things to work correctly.

While using information found on the Web is usually free, I still like books. So, I bought a book: "Internet of Things with ESP8266," by Marco Schwartz - in PDF.

After spending several hours on the small project of getting a DHT11 sensor to work with my nodeMCU, I finally figured out that my DHT libaries were out-of-date. The simple solution was to install Adafruit's DHT library and their Adafruit_Sensor library.

Here is the link to using a DHTXX sensor on Adafruit:

My setup is seen below:

The thing to realize, when you use an ESP8266 module of some sort. is that you need to know what pins are being used in the Arduino code. Here is a typical image of a nodeMCU layout:
A little hint: when you go to write your code in the Arduino IDE, make sure you use the correct pin. Looking at the layout above, D1 is GPIO5. In a typical DHT11 example program you will see digital pin 2 used to get data from the sensor. I changed that to 5, as was in the code in the book. The point is that nodeMCU pins will often not work with with Arduino board code and changes will be needed. Then you also have to make sure you are getting the correct numbers for whatever ESP8266 module you are using.

I will not bother posting the code as you can find it online in different places. Hopefully, it will be enough assistance to those with similar problems in keeping their libraries up-to-date. I guess that is my own lesson as well. If I come across more problems that I are worth posting, I will.

Friday, 6 October 2017

Raspberry Pi User Group Meeting, September 24, 2017

RPUG had its first meeting of the season Sunday, September 24, 2017, 2-5pm.

Where?       New Glasgow Library
                   182 Dalhousie Street
                   New Glasgow, NS

We will be meeting the 3rd Sunday of the month for the rest of the season. Easy to remember but here is the list of the dates:

October 15, 2 - 4:30pm
November 19, 2 - 4:30pm
December 17, 2 - 4:30pm
January 21, 2 - 4:30pm
February 18, 2 - 4:30pm
March 18, 2 - 4:30pm
April 15, 2 - 4:30pm

Once the library closes on Sundays for the season we will be considering whether or not to continue for a couple of months on Saturdays and then stop for the summer.

As I needed the photocells for another project this summer, I took the mounted ones from the robot. During the RPUG meeting we decided to figure out how the line sensor works. Here is a picture of the underside of the robot with the line sensor on the right:
We connected the line sensor to the Boarduino, wrote a quick sketch to test it, and started figuring it out. The nice thing about sensors connected to Arduinos is that many of them have three connections: power usually at 5V, a common or GND, and a signal. The signal tends to be an analog voltage. However, because Arduino often uses the PWM pins to simulate an analogue voltage, I will be checking the output signal of this line sensor with an oscilloscope. If it is truly an analogue output signal, the reading on the oscilloscope will be a steady level voltage. If uses PWM to simulate an analogue voltage, the output will be a rectangle wave with high side, the duty cycle varies with the higher the voltage.

What the ADC sees on the Arduino is that the voltage from the sensor signal actually takes time to fall to zero. If not, the ADC would have to provide numbers that reflected both high and low values of the signal. This topic can be searched on the Web if more is needed.

Here is a simple sketch to test the line sensor:
/* program: robot_line_follow_2_blog.ino
 * This program is used to test the line sensor only.
int line_sensor = 0;  // variable to hold data from reading infrared sensor on A3

int analogPin3 = 3; // the line sensor is connected to this ADC

void setup() {
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);

void loop() {
  int drive_type;
  Serial.println("Inside loop");
  line_sensor = analogRead(analogPin3);
  Serial.print("line_sensor = ");


When the sensor is first tested, it could be that it is not adjusted properly. We figured that out without too much experimenting and without looking up a tutorial online. In the picture there is a trim pot with a white top that allows for a Phillips head screwdriver. With the sensor powered, turn the pot until the red LED turns on.

At that point, when the program runs, the red LED should shine and placing something black under the sensor will turn the red LED off and the readings will change from a low number (around 8 to 12 with no dark object) to a high number (around 800 to 920 with a dark object). When this happens, you know the line sensor works properly.

It might happen that your line sensor goes from on to off when you set the robot (or whatever your project is) down. Readjust the trim pot and set it down again. Keep adjusting the trim pot until the red LED stays lit. Test again.

What happened to us when we first tested it were ADC readings that varied from  800 (no black object under the sensor) to approximately 920 (with a black object under the sensor). You could operate your line sensor that way and write your program accordingly. This might even be useful if your line to follow might be some other colour than dark black. The red LED was not lit when the line sensor was used in this manner.

We also took some time to test the motors by using some arbitrary programming. The idea was to get the robot to turn one direction and then the other. It only turned left and periodically more sharply left than others, even when it was told to go right. Looking back it is, what was happening was the use of PWM on geared motors needs the motors to be signalled to completely stop or changed direction for a long enough period of time so the momentum does not carry the robot through its last turn.

Look for some general electronics tutorials in the future, especially to be provided at the RPUG Meetings. I am currently working on one involving 555 and 556 timers - Forrest Mims' Stepped Tone Generator (on the Web aka APC or Atari Punk Console). Another planned tutorial for the near future is a commonly found Four Op Amp Function Generator. However, my addition will be control of frequency using an Arduino to provide high resolution control with an R-2R Ladder Network DAC. It would be in the neighbourhood of 16-bit resolution with two 74HC595 shift registers. Of course, some of these will also look on putting an RPi spin on the topic.

Sunday, 18 June 2017

Raspberry Pi User Group, June 17, 2017

Happy Father's Day to all the fathers out there, and their families!

Today is also the day of the Johnny Miles marathon and we still have runners going by the house. Lots of the energy there!

Raspberry Pi User Group Meeting, June 17, 2017
Place: New Glasgow Library, New Glasgow, NS

Arduino / Python Serial Communications Using PySerial:

We had a Raspberry Pi User Group Meeting yesterday, June 17th. I was working on my robot yesterday. I am working through some tutorials on YouTube about Arduino and Python Serial Communications. I had looked up a number of tutorials online and worked through a couple of them. However, whenever I tried to do something that expanded on the ideas presented, it never worked. That is why I did some more searching and found the topic above.

Here is a link to the first video of a good set:

These videos are short and very relevant to how I want to use an Arduino and a Raspberry Pi Zero Wireless together on my robot. To make things really simple, I am using a USB cable to interface Arduino and Python. For testing and learning purposes, I am using a PC running Ubuntu with my Arduino. Using Linux and Arduino really cuts down on prototyping time as the programs compile and upload very quickly with such a system. It also works fairly quickly to actually develop on the Raspberry Pi Zero W but, there it time to go back and forth between the RPi and a PC to view any kind of web-based tutorials.

By the way, this topic uses PySerial and works with Python 2 and Python 3.

The Robot:

This is my robot in its current state:

This is a mess of wires! However, if you take the time to look through the wires,
you can see the USB Boarduino in the middle, the photocells are to the left setup as voltage dividers with the resistors in the breadboards. The new additions as of late are the H-bridge motor drivers on what is the front right and right side of the robot. I placed the RPi Zero W and a USB hub to give an idea of what is to be added. It looks like I will have to add another layer to the chassis to fit the other devices. I might also add a 16x2 LCD and some push buttons. Once I get it going, I will consider refactoring it by soldering together some permanent circuit boards for the H-bridge motor drivers and the photocell/resistor voltage dividers to free up the solderless breadboards.

Underneath are the geared motors with wheels, the battery pack with
rechargeable batteries, and the swivel caster wheel. The battery pack is held in place with two elastics. You can also see the IR sensor on the bottom that will allow the robot to be line-following. It is not hooked up yet as I have not made it light-following yet.
 The motors work and so do the photocells. I need to normalize the three photocell/resistor voltage dividers to allow for easy programming of signals going to the motor drivers. That way it will follow light uniformly for light shone on all three photocells.

PAW Server:

For a change in direction, and possible use on a robot at some point, we checked out running a web server on an old Android phone. I chose a tutorial on the PAW Web Server which is a simple app that runs on Android without having to root the device. It has some excellent features but keep in mind that a single-core 800 MHz, 512 MB RAM device will not run much at blazing fast speeds.

All the same, it is fun to use a webcam server, robot text-to-speech, and of course, serving up actual webpages. There is too much to describe but it looks very useful and the interface is very easy to use. Just search for tutorials on the PAW Server and you should find something to guide through orientation.

List of Topics To Date:

Here is an updated list of things we have worked on or covered in some way, to date:
  • Raspberry Pi radio - your own little FM broadcaster!
  • Command line music players and how to use them to edit music files
  • FlightRadar24 - watch airline data
  • How to set up your RPi the first time
  • Minecraft Pi workshop - programming in Python to make your own custom Minecraft game
  • How to make an LED turn on and off using Python and RPi General Purpose Input/Output (GPIO) pins
  • Free RPi material such as magazines and short books provided by "The MagPi" magazine
  •  Setting up your own private LAN (not Internet accessible). This is useful for places where organizations keep their own Internet Accessible LAN locked down. This means you cannot do simple things such as using SSH to login into your RPi. If you set up your own private LAN, you can connect both your PC and RPi and login remotely using SSH.
  • Run a servo motor using Python.
  • RPi 3 as desktop PC replacement - would do if that was all you had but, not really recommended.
  • RPi 3 - 3.5 inch touchsreen
  • Starting to explore Arduino/RPi Zero W USB communications (same as Arduino/Python Serial Commuinications)
  • Forward/Reverse Relay modules
If you would like to see something specific covered, drop me a line! You can also drop by the meetings once they resume again in September, 2017.

Wednesday, 7 June 2017

Raspberry Pi Zero W and Arduino Robot, June 7, 2017

Here is a quick post to show the current state of my robot. It is currently to the point where I have all the necessary components except maybe the transistors necessary to make H-bridge motor drivers for each wheel. I have transistors that might work but have not built an H-bridge to test them. I am using geared motors, a USB Boarduino, an RPi Zero W, some mini solderless breadboards, a powered USB hub, three UBEC's that supply 5V, 3A, some photocells, an 8-cell AA battery pack with rechargeables and a homemade chassis from plywood.

The photo shows everything running from AC/DC adaptors at moment. However, everything has been tested with homemade USB power cables. I just hope I do not make the mistake of plugging in the positive and negative of those USB cables into the same connection. I saw a recent product that offered the same power from a USB port that ran the power connections out to red and black shrouded alligator clips. The tweet said an accident waiting to happen!

Current state:

At the moment, with the programs I am running, I can send a number from the RPi Zero W by USB to the Arduino and have the Arduino light up and LED that number of times. The next stage is to use directional controls commonly used in video games, W, A, D, and S, to light up the LED's. I would also like to be able to adjust the brightness according to how long I hold down the directional key using PWM on the Arduino.

That way I know the current setup is ready to accept a more fully developed program that will accept both directional controls using Python on the RPi Zero W as well as using the photocell light sensors. Keep in mind, PySerial is used.
After finding a number of different tutorials on using PySerial with an Arduino, here is the one I found the most useful (easiest to use and mod to my purposes):

My apologies if the code does not copy correctly. I copied and pasted the code into Blogger then edited it where needed. Here are the two programs I am using to control the LED's at this time:

Python code:
# program:
# This program sends data from the RPi over USB to an Arduino and receives
# that data back - repeated. The data sent to the Arduino controls the number
# of times the LED's light up on the Arduino.
# The pair program for the Arduino is receive_from_pi_light_leds.ino
from time import sleep
import serial
ser = serial.Serial('/dev/ttyUSB0', 9600) # Establish the connection on a
# specific port

counter = 7
# testing number, 48 is the character 0, zero, 57 is 9
# Below 32 everything in ASCII is gibberish
  while True:
    ser.write(str(chr(counter))) # convert the decimal number to ASCII then 
                                 # send it to the Arduino
    print "counter = %d" % counter
    print ser.readline() # read the newest output from the Arduino
    sleep(0.5) # delay from 1/10 seconds
    if counter == 255:
    counter = 32


Arduino Sketch:
// program: receive_from_pi_light_leds.ino
/* This program receives data from the RPi over USB and sends data back. Before
 * sends the data back, it calls a function to light one or more LED's according
 * to the data received. 
int led1 = 13; // led is connected to digital pin 13 
int led2 = 12;

void setup() { 
  pinMode(led1, OUTPUT); 
  pinMode(led2, OUTPUT);
  Serial.begin(9600); // set the baud rate
  Serial.println("Ready"); // print "Ready" once

void loop() {
  char inByte = ' '; if(Serial.available()) { // only send data back if data has been sent
  char inByte =;  // read the incoming data
  Serial.println(inByte);  // send the data back in a new line so that it is $
                             // all one long line
  else if(!Serial.available()){

void light_leds(int n) {
  for(int i = 0; i < n; i++) {
    digitalWrite(led2, HIGH);
    Serial.println("inside light_leds");
    digitalWrite(led2, LOW);
  Serial.println("light_leds END");
  Serial.println("going to stop_go");

void stop_go() {  // does nothing at this point

Sunday, 4 June 2017

Raspberry Pi User Group Meeting, May 27, 2017

Next Meeting:    June 17, 2017, 10am - 2pm @ New Glasgow Library
Check out New Glasgow, NS for current ads.

Unfortunately our date had to be changed from our regular Sunday to a Saturday due to the library closing on Sundays halfway through May to the beginning of September. We did have the new date posted on our Kijiji ad but the message did not get out to some people - sorry about that.

There was some time at the beginning of the meeting where I was by myself. I took the time to work on my robot. Connecting the photocells was the first job. I had one photocell connected more or less the way I wanted by the time the first attendee arrived.

Here is the robot with just the photocell (light) sensors and one solderless breadboard, and wheels with geared motors. The screws for the third wheel (a caster wheel) can be seen in three places. To start with, I originally used a screw that was too long for the job. Grounding it down so it would not interfere with anything that might be placed on that section of the robot was too much trouble. Although I left the one ground down screw in place, I went and bought the correct length screws for the rest of the caster wheel mounting holes.

Here are is the robot with LED's connected so that they light up according to which sensor has the most light shone upon it. The LED's are on the far side of the board behind the light sensors.

Our attendee had some modules he wants to use to construct his model train environment. We started off with a forward-reverse relay module purchased from eBay. These modules were from China but had some decent documentation in English. Once we started to work with them, we figured it out. We also found the eBay listing for the same module and watched the video which was close-captioned in English. Watching it in action on the video helped.

One interesting thing we found was that the model train power supply was not not appropriate to run the relay modules. One of them just would not power up. Luckily, we had an Arduino board from which we used the power supply. So, if you are into model trains or interested in getting started with model trains, make sure you have at least one good power supply to test your equipment.

Here is the link to the module:

In the case of testing the relay module, we did not provide a load to switch on so we only had to worry about the current and voltage necessary to run the module electronics used to determine the timing for the forward-reverse cycles. We did not have to worry about the power supply for a motor or how to hook one up. We could hear the relay switch when it powered to indicate it was working.

When borrowing the power supply built into any board, you should have a quick look to see what the power supply circuit can handle. You can do this for Arduino by going to the Arduino website and looking for the relevant board. Look for the hardware schematic. For an Arduino from 2009, the voltage regulator is an MC33269. One of the key properteis to look at when reading the data sheet is the maximum current supplied by the particular device. In the case of the Arduino board, you should also check for Arduino documentation to see if there is anything specific done to the voltage regulator that allows for less or more current than normally supplied by the voltage regulator. Do a web search on the part or go directly to the manufacturer's website to find their data sheet. There are also some sites that provide data sheets from most manufacturers.

We had another module to search for: a servo motor shield. This was easy as it gave the manufacturer on the Arduino shield, what is was, I cannot recall. Do a websearch on "Arduino motor shield" and you will come up with a number of results that will likely serve your purpose. If the websearch provides you with an acceptable result, you should be able to find a relevant tutorial.

Come see us at the library Saturday, June 17, 2017 to see what new things we are using and troubleshooting. The robot should be able to follow light by then! If you look closely, you can see that there is actually no RPi on the robot yet! Give it time.

Saturday, 13 May 2017

Raspberry Pi User Group Meeting, April 30, 2017

We had somebody new come in to see what we had to offer Sunday afternoon on April 30th. Our guest had a 3.5 inch touchscreen purchased from eBay that he wanted running. We had not done this before ourselves but were quite comfortable looking up different sites for specific resources and tutorials. We quickly found something that almost had all the functionality working. We could not get all the capabilities working for the touchscreen but it worked with a keyboard and mouse. Given a little more time and knowledge we could have figured out the specific problem with this particular distribution of Raspbian.

The rest of the afternoon was spent working through a couple of tutorials of programming an Arduino with a Raspberry Pi Zero Wireless and serial communications via USB cable. What a great little system it is that allows such a small computer to program and operate an Arduino. The RPi Zero Wireless has a processor about equivalent to the original RPi Model B and 512MB of RAM in a size less than half an RPi 3, Model B. The intended use of this type of setup is to run a motorized robot with a good amount of computing power with the stable motor driving and miscellaneous electronics peripheral capabilities. For instance, servo motors are more stable using an Arduino compared to an RPi. Keep coming back and you will see something develop.

If you have not checked us out on, we meet about once per month on a Sunday at the New Glasgow Library. We are usually listed in their events which can be found here:

Our next meeting is May 28th, 2 - 5 pm.

If you are interested in us, make sure you look up the correct library. We meet in the Community Room at the New Glasgow Library. There is also a Raspberry Pi, Model B, available for anybody to come in a use on request. I recommend a little reading about it before you use it. This goes for all people who have not really used a DIY electronic device with any number of electronics pins (aka in electronics as GPIO) used to connect things like LED's and pushbuttons.

V = IR is a good equation to know how to work.

Basically, if you connect an LED to a pin, make sure to use a resistor of at least 100 ohms. If you neglect to use a resistor or use a resistor of too low a resistance, you will permanently lose use of that pin or sometimes worse. Do a websearch on the subject and you should find lots of tutorials. Check out the blog post here for a specific application:

The great news is that you can still use the Raspberry Pi with very little electronics knowledge just as a computer. It does all the major things that a computer will do such as listing files and directories, making files, editing files, changing file permissions, working with shell scripts and the like.

A great resource is The Magpi, the Raspberry Pi magazine which can be found on the Raspberry Pi website. You will find lots of reading material and projects in this magazine. It also has a great and growing collection of small PDF's on essential subjects that help in the process of getting to know the Raspberry Pi, including one on the DIY electronics.

The link below will get you to the RPi site. Have a look around - it is worth it to find out about the RPi.

If you are uncomfortable with plugging things into the Raspberry Pi but still feel the desire to make something turn on and off, try looking up a video on the subject. It will help immensely. You can find a large number of videos on how to connect things safely, though not necessarily having safety in the title. A little knowledge goes a long way. At the same time, use common sense. An LED is a great device to learn how to use. First try using an LED, a 9V battery (no higher), a current limiting resistor, and necessary jumper wires.

Saturday, 18 March 2017

Raspberry Pi User Group Meeting, March 12, 2017
Location: New Glasgow Library, Nova Scotia

Great news! We keep getting requests for both streaming our meetings as well as people wanting to take part in person. There is not a strict criteria for taking part in our group. It helps to have an interest in technology, but if you just want to see what it is that we are using Raspberry Pi's are that are not produced in the kitchen, come join us.

We post our meetings on under the Nova Scotia > New Glasgow > community > activities, groups. That chain of selections should bring you to the section where we post our monthly ad.

This should also work:
If the above link does not work, again just follow the chain provided above.

We had three main focal points on March 12th:

1) Setting up a local network so we could play a Minecraft game at the library without getting permission for their network at the library. They keep it locked down so that you cannot SSH into your Raspberry Pi like you can at home. Many people have an old wireless router at home as an extra device that might not be used anymore. Techies tend to keep this stuff around or pick them up at yard sales or the flea market. It makes it really easy to run your RPi headless as well.

Google the topic if you want to know more. By the way, this is a very easy way to run your RPi headless. Simply connect your RPi to the wireless router, connect your laptop to the router (both using the device connections, not the Internet connection), find the RPi's IP address on the new network, and you can use Putty or some other program to SSH (simply ssh in Linux) into your RPi. Sometime soon we will have a look at running VNC to connect to the RPi so we can use the other PC to get the RPi full desktop's GUI.

2) Servo motors! We ran a regular standard servo motor using a recipe from the Raspberry Pi Cookbook, 1st ed. However, the cookbook recipe uses Tkinter to make a simple GUI. Great if you know Python already but I am just not there yet. I need to learn some more Python before I get into using one of the different modules that can be implemented to make GUI's. So, in the end , I went to the Adafruit site to check out one of their tutorials on servo motors.

I have no affiliation with Adafruit. They are just a great resource and sell some really cool stuff. I purchased one of the POV devices a few years back and like it.

By the way, to avoid problems running servo motors when you follow the Adafruit tutorial on setting up a single servo, make sure to follow the instructions on this link:

Adafruit likely already has lead you through this material if you follow their tutorials on the RPi from lesson 1. Many an RPi user has not, so this is good information to have. If you do follow the Adafruit tutorial on the single servo motor, make sure to follow the WiringPi page on the Python site given above, before you get to the Software section.

The idea of having control over the servo and knowing what all parts of the program are doing, at least within reasonable knowledge, is appealing to me. I do not claim to know what all modules (libraries) have in their code. Have a look through some modules and you will get an idea of how much things are really simplified for the new programmer as well as the seasoned one.

3) We had a question about an RPi replacing a regular desktop computer. It is possible but even with the RPi3, I would not recommend it. The RPi3 is a huge improvement over previous versions but it is not on the same level as most of the regular PC's available today. You can watch YouTube without many pauses for buffering or doing many other tasks.

It is a good idea to try things out for yourself on your RPi to see just what it can do - a lot. It does play Minecraft Pi very well, even a networked game. By the way, using Minecraft Pi is a great way to learn Python. There are books out there on the topic - both paid and free resources. I keep telling people that The MagPi offers lots of material for free. Be sure to check out the links on the RPi site:

Up for the next meeting on April 30th: motorized robots!

Friday, 24 February 2017

RPUG Meetings: Topics to Date - February 24, 2017

The Raspberry Pi User Group (RPUG) has met since November, 2016. Our numbers are small but we are growing slowly. Interests include the Raspberry Pi, but as anybody knows in DIY Tech circles, most of us have many interests such as:
Linux in general,
Ham radio,
Hardware and Software Synths, both purchased and DIY,
Atmel and PIC mcu's (both now under the MicroChip umbrella),
DIY metal-smithing, and
I am sure dozens more interests.

In our past meetings we have covered to some extent the following topics:
  • Raspberry Pi radio - your own little FM broadcaster!
  • Command line music players and how to use them to edit music files
  • FlightRadar24 - watch airline data
  • How to set up your RPi the first time
  • Minecraft Pi workshop - programming in Python to make your own custom Minecraft game
  • How to make an LED turn on and off using Python and RPi General Purpose Input/Output (GPIO) pins
  • Free RPi material such as magazines and short books provided by "The MagPi" magazine
In our March 12th meeting we will cover operating a servo motor with the intent of building a motorized robot.

Learn basic electronics as you go along building different projects!

Monday, 23 January 2017

Arduino, Blinking the LED, and the Capacitor

Arduino and Flash an LED Tutorial  - and a Capacitor

What You Will Find in This Tutorial:
    I worked on only giving the necessary simple things in the Bare Bones section. It will allow you to learn how to connect the circuit from looking at the schematic. You will also see the sketch (aka: program). There is also a picture of an Arduino board and the major parts are pointed out.
In the Extras section you see a schematic using two resistors, the LED and an electrolytic capacitor (be careful with electrolytics!) to fade in and out the LED. There are also some pictures of traces of the signals as applied to the circuits so you can see what is happening that way. There is some explanation in this section. It turned out to be a good refresher on using an oscilloscope and analyzing how resistors, capacitors, and one of the basic ideas of how Arduino GPIO pins work.

    Make sure to use equations necessary as well as schematics. Graphs can also be used.

Materials Needed:
1) 2 LED’s of any colour
2) 3 current limiting resistors, 1kohms.
3) One 50kohm potentiometer
4) 1 x 1000 uF electrolytic capacitor
5) Any kind of Arduino board
6) Jumper wires

  1. Oscilloscope
  2. Digital Multi-meter (DMM)
  3. Jumper wires with alligator clip ends

    This section gives you just the necessary information to do the tutorial. It does not give a lot of background information. If you do not understand something, take the time to read the whole tutorial, at least to the end of the Bare Bones section. There might also be some information useful to you at the end of the tutorial where I elaborate a little on some of the tutorial - such as looking for specification sheets.

Step 1:
The basic parts of an Arduino board:
>USB jack - connects the Arduino and the computer
>Labelled in red in the picture below
>The power section pins
>Labelled in red below - take note that the Arduino designers have left one pin in this section to be used for a purpose yet to be determined. That is the pin on the left.
>The Tx (labelled TX->1) and Rx (labelled RX<-0) pins - On the upper side of the board in the picture
>labelled in white.
>The rest of the digital IO pins including Pin 13
>also labelled in white
>The analog input pins
>labelled in white - beside the power section pins
>The Power Jack
>labelled in red and located below the USB Jack. It is used when making projects that require more current than the USB port can safely provide.
Step 2:
    The most important equation used in electronics:    V = IR
    This is also one form of Ohm’s Law in case you want to look that up later.

Most LED’s have a forward voltage of Vf = 1.7V to 2.5V.
Use the concept of voltage drops as shown in the schematic below:

Here are the voltage drops in the circuit above:
VTotal = 5V
VLED = 1.8V            AKA: Vf of an LED
VR = VTotal - VLED = 5V - 1.8V = 3.2V
Now, what do we do with that information - determine the value of current limiting resistor to use.

We have VR. We need to find R. How do we find I? Looking at a specification sheet will tell you that typical If for a red LED is 20mA. See more on reading specification sheets at the end of the tutorial.

Solve for R:
R = VR / If = 3.2V / 20mA = 160 ohms.

In practice, most LED’s will work fine with R = 100 ohms to 1kohms. Anything less than 100 ohms and you really need to be sure of your math so you do not burn out the LED and possibly the GPIO pin on your device.

Step 3:
Build the circuit. Use the schematic above for reference. The picture below can also be used for reference. Take note of the labels of the rows and columns.
Choose a resistor of appropriate value between 100 ohms to 1 kohms.


Take a jumper wire and plug it into Pin 2 along the Digital side of the Arduino. Pin 2 is beside digital Pin 1, which is marked on the Arduino as TX->1.
Plug the other end of the jumper wire into a column on the breadboard.
Take the chosen resistor and plug on end of it into the same column as the jumper wire on the breadboard.
Plug the other end of the resistor into another column in the breadboard.
Take the anode of the LED and plug it into the same column as the free end of the resistor.
Plug the other end of the LED, the cathode, into another free column of the breadboard. HINT: LED’s come with the anode longer than the cathode.
Plug in a jumper wire into the same column as the cathode of the LED.
Plug in the free end of the jumper into a GND pin on the Arduino.

Step 4:
Write your sketch (aka: program) in the Arduino IDE. Below is an example.

// program: blink_led.ino
// The double forward slashes indicate comments. This type of line is used to explain
// things in a program. This helps when you are not familiar with things and need a
// reminder. It is also used to help others understand what your code does.
/* Comments can also be preceded with the first two characters of this line and 
succeeded by the last two characters. This allows comments to span more than one
line in a sketch. */

int led = 2;

void setup()
    pinMode(led, OUTPUT);

void loop()
    // turn LED on
    digitalWrite(led, HIGH);
    delay(1000);            // 1000 is 1000 milliseconds, 500 is 500 milliseconds
    // turn LED off
    digitalWrite(led, LOW);

This is the first sketch that everybody uses to check to see if their Arduino is working. Once your sketch is typed in, save it using the name provided at the top, file extension is not included as the Arduino IDE will add it.

While writing the program, I mistyped pinMode() as pinmode(). It did not compile correctly and gave me an error message in the Console. Take the time to read the error messages that appear there. While you might not understand them at first, you will become familiar with them and they will help you debug your program.

Try mistyping the same command in your program. Compile it or try to upload it and see the error message provided.

Step 5:
Get into better programming right away: Setting up the serial terminal for manual debugging.

At some point, quite possibly even during typing in this sketch, you made a mistake and the program did not compile properly, did not upload, or did not operate as expected.

If it is one of the the first two problems mentioned, then you need to check the Console for error messages. The Console is the black area at the bottom of the IDE. You can copy them and paste them into a search engine in your web browser to find out what they mean. Read them first to see if you can decipher what they mean.

Here is a link to the Processing IDE parts (I could not find one for Arduino. The Arduino IDE is based on the Processing IDE.):

In the setup() function, type the following to initiate the Serial Terminal.

In the loop function type the following line after the part that turn on the LED:

After the part that turns the LED off, type:

Save your sketch under a new name such as:

Remember that you do not have to type in the .ino file extension during the Save process.

Upload the program to your Arduino. Click on the Serial Terminal icon in the upper right side of the IDE. It looks like a little magnifying glass.

You should see a series of ON/OFF messages in the window that pops up. The messages will appear almost at the same time that the LED turns on and off.

This becomes useful as you learn more about programming and your sketch uploads but does not operate the way expected. You can place Serial.write(); statements wherever needed in the sketch so you can see the values of variables as they are used. You can become quite inventive in your debugging, making use of all kinds of statements and functions to help with your debugging.

An example would be to include an extra delay(); statement in your sketch so you can have the time to examine the variable printed in the Serial Terminal. The Serial Terminal also will accept input to be transmitted to the Arduino so be sure to look that up. That can also be used as a trigger in your sketches.

Since we are talking about the Serial Terminal, you should know that GPIO pins 0 and 1 are used to Receive (Rx) and Transmit (Tx) (see picture of Arduino above for labelling)    . You should avoid connecting things to these pins as they perform those special functions. Yes, learn a little more about them and you can do different things, but I do not have that experience.


The common point referenced in schematics is more often than not called ground. However, do a little reading and you will find out that ground should be used when referring a common connection that is made to a wire or some other connection that goes to ground, actual earth.

Ground and common are parts of the same topic that should be investigated. With many circuits, there is no real ground, just a common. However, that statement, or anything else in this post are the final word on the topic. You should do some reading on the subject.

Using Capacitors to Fade Out an LED:

When first using electrolytic capacitors you should wear safety glasses. If plugged in the wrong way they can pop and expel harmful substances. The negative side of an electrolytic capacitor is marked with a line as seen in the picture in Step 3).

On to using capacitors in a way that allows the LED to fade out instead of blinking out.

A capacitor holds an electrical charge. That charge can be positive or negative. When placed the wrong way in a circuit, they can explode and expel harmful materials that can cause a chemical burn. That is a topic you can research on your own.

Here is a simplified circuit that can be used as an experiment if you want to work out the time it takes to charge a capacitor. Luckily, the circuit used to fade an LED out with an Arduino is not a whole lot more complicated.

Below is an equation used to determine how long it will take to charge capacitor, C.You will want to reference the 2nd equation. The first equation is there if you want to use it and look at a graph of the instantaneous voltage level plotted against time. The value can then be thought of as chunks of time it takes to charge the capacitor. Do a websearch and find out how that looks.
is the instantaneous voltage at time t. Remember that a charges, and it takes time to charge a capacitor. The lower the resistance between the charging voltage, the faster the capacitor will charge.
is the final voltage. Using an Arduino GPIO (General Purpose Input/Output) pin,
the final voltage will be 5V.
is the mathematical constant Euler’s constant.
is the time constant, = RC

So the equation can also be written as:
This is a more convenient equation to use to figure out how long a capacitor to charge given a known capacitance and resistance in the circuit.

Let’s use something simple like:
R = 1k
C = 1F
= 5V        The standard voltage level of a GPIO pin on an Arduino Uno or Mega.

Sorry for the units being all over the place. Google Blog does not like it.

= RC = 1kohm x 1uF = 1ms  = 1/1000s

Take 6RC = 6(1ms) = 6ms

6ms is not very long.

The plot above is a rough approximation of the instantaneous voltage, . What it does show is that it takes about 6 units of to fully charge the capacitor. The plot is an approximation and what is not represented is that the charge will never actually reach . 6 is 6ms, as mentioned above. Using a capacitor with capacitance of 1uF will allow the LED to fade in and fade out, just not at a speed that the human brain can detect.

Step 6:
To understand how fast a millisecond is, you can do an experiment with the materials you have on hand and the circuit you have already built. Using the sketch, take out the following commands in the sketch:
Serial.begin(9600);        and
Serial.write(led, HIGH);    and
Serial.write(led, LOW);

Removing those statements will speed up the program for what you are about to do. Serial communications take time and to keep the write statements in the program while changing HIGH and LOW states of the LED would slow things down too much. It would not really be useful for this part anyway.

At the moment, your sketch is a very simple program that turns an LED on and off at the rate of 2 seconds on and 1 second off. You are going to shorten the on and off cycles down to 10’s of milliseconds or less and see at what point you can tell that the LED is no longer blinking.

It should be around 20ms or less.

Now, you can understand why you need longer times to let the capacitor charge and discharge. You can do two things to allow the time unit of to be longer. You can change the resistance and you can change the capacitance. To change the resistance it would be useful to use a potentiometer so you can change the resistance value. If you do use a potentiometer, connect it as a rheostat and not as a voltage divider.

Step 7:
To change the capacitance, you will have to go up to about 1000uF to make a nice decent fade-in and fade-out. You will have to use an electrolytic capacitor to get up to 1000uF so be careful when connecting it. Putting an electrolytic capacitor in backwards can cause it to pop, even expel the harmful material inside. Take care to use safety glasses.

Using the same resistance and a 1000uF capacitor will increase by 1000. Now:
= RC = 1kohm x 1000uF = 1s

New Circuit and the First Circuit:



There are two important things when dealing with capacitors:
1) Whether or not it is electrolytic and
2) The voltage rating.

  1. Do not put in an electrolytic capacitor in backwards.
  2. Use a capacitor with the proper voltage rating. If the voltage rating is too low, the capacitor’s dielectric will not be able to withstand the voltage differential between the polarities which it handles.

Using both circuits will make it easier to see how much the LED with the capacitor fades in and out.

Below are two photos of the oscilloscope probes attached to circuits. The yellow trace is the signal from the probe attached at a point between Pin 3 on the Arduino and a 1kohm resistor. The blue trace is a probe attached to the circuit attached to Pin 2 of the circuit. The difference between the two traces is that the circuit attached to Pin 2 on the Arduino uses the circuit with the 1000uF capacitor.

The two traces show how the capacitor charges and discharges to allow the LED to fade in and fade out. The charging/discharging cycles are shown clearly.

2 Seconds On, 1 Second Off:

6 Seconds On, 6 Seconds Off:

If your LED with the capacitor is not fading in and out nicely, try using longer delay times. Remember that a command:
Means the program will allow the HIGH or LOW state to happen for 1000ms.

Allows the program to have HIGH or LOW for 2000ms = 2 seconds.

Another useful bit of information is that when the capacitor discharges, the current actually does flow in the opposite direction after the LED turns off completely. So the current discharges from the capacitor and after the forward voltage drops below the forward voltage of the LED, the capacitor is forced to disharged the rest of its current back into the output pin. This is possible and used in some cases where somebody might want a lack of voltage to make a transistor turn on. Do a websearch on the topic.

Math shows that the voltage drops across the resistors should be 1.65V when the forward voltage is 1.7V. Measurements show forward voltage to be 2.6V.

Using the forward voltage to be 2.6V gives the following:
VTotal = VF + VRTotal
VRTotal = VTotal - VF
VRTotal = 5V - 2.6V = 2.4V
ITotal = VRTotal / RTotal = 2.4V / 2kohms = 1.20mA
VR1 = ITotal x R1 = 1.20mA x 1kohm = 1.2V

This works out to be fairly close to what is measured in the circuit. Each resistor had a voltage drop of about 1.1V.

Step 8:


The interesting thing about the circuit immediately above is that the LED does not fade out as with the previous circuit. It looks like the LED turns off when there is not the necessary forward voltage.

NOTE: Fading an LED in and out of the On and Off states might not be the best choice for such a task. It is probably done more easily using the Arduino Sketchbook example called Fade. Fade can be found in the IDE Examples section under 01. Basics. The Fade sketch uses a PWM ability. PWM stands for Pulse Width Modulation. If you look at the two pictures of the oscilloscope traces above, you will see that the yellow trace is a square wave. PWM uses a square wave and changes the amount of time in the HIGH or On position to change the brightness of the LED. An explanation is found on the Arduino side here: 
While the capacitor might not be the best use of components, it does cut down on code, but probably not a whole lot. However, if you have taken the time to work through this part of the tutorial, now you have a good idea of how capacitors work!


When choosing resistor values, here is the catch. All components are not completely accurate. Most resistors have a tolerance of +/- 5%. That means that a 1 kohm resistor can have value 50 ohms above or below 1000 ohms ⇒ 950 ohms to 1050 ohms.

If you do not know already, you should do a websearch on resistor colour code and learn the values. Here is a quick chart to show you how the values relate to the colours on a resistor:

Resistor Colour Code Chart


+/- 1%
10^2 = 10 x 10
+/- 2%
10^3 = 10 x 10 x 10








+/- 5%

+/- 10%

Resistors most commonly have 4 colour bands on them. There are also 5 bands on some resistors. The colour chart for 5 banded resistor is almost the same as 4 banded resistors. You can see the difference in how the two similar colour codes are applied below.

Here is a representation of a 4 banded resistor:

                             Red    Violet  Brown       Gold
                             2          7       1                =/- 5%     = 27 x 10^1 +/- 5% =  270 ohms +/- 5% 

 5 banded resistor:

                          Green Blue Black Orange     Red
                          5         6       0        3               +/- 2%    = 560 x 10^3 +/- 2% = 560kohms +/- 2%

Step 9:
The other important thing to know when working with resistors is the power dissipation rating. Most of the resistors that people use when learning and experimenting with electronics are ¼ Watt or 1/4W resistors. They are also through hole which means they can be easily handled using fingers. Surface mount electronics require a lot more practice to use effectively. A lot of modules you will see when working with electronics use surface mount electronics because they can make the cost of building the module less expensive.

Power dissipation is important to know because if you get too much current flowing through a resistor, it will burn out. This can will ruin your resistor but also can damage the rest of your device. Usually, when using an Arduino and just lighting up an LED, this means burning out the GPIO pin but more can happen.

Let us use two examples here. Here is the first schematic:

First, use the values in the schematic to calculate power dissipation through the resistor. After that we will also calculate the power dissipation of the LED.

Equation to use:

P = VI

The power equation also comes in two other forms:

P = (I^2)R         and
P = (V^2) / R

They all work out the same but sometimes you cannot get one value or another in a circuit and need to use one of the other equations.

Using the following equation (remember, a form of Ohm’s Law):
V = IR

You can substitute in the values to get the other equations.
Here is one example:
P = VI = (IR)I = I^2 x R = (I^2)R


VTotal = 5V
VLED = 1.8V            AKA: Vf of an LED
VR = VTotal - VLED = 5V - 1.8V = 3.2V

ITotal = IR
The above equation is true and useful because all the components in the schematic used are connected in series. This means that the current that flows through the resistor is the same amount of current that flows through the LED.
Just to be thorough, all three power equations will be shown. But, first the current will be calculated:

IR = VR / R = 3.2V / 1kohm
IR = 3.2mA

P = VI = 3.2V x 3.2mA = 0.0102W = 10.2mW

2nd Power Equation:
P = (I^2)R = (3.2mA ^2) x 1kohm = 0.00001024mA^2 x 1000 ohms = 0.0102W = 10.2mW

3rd Power Equation:
P = (V^2) / R = (3.2V ^2) / 1kohm = 10.24V^2 / 1000 ohms = 0.01024W = 10.2mW

The reason it is important to calculate the power dissipated in a resistor is so the resistor does not burn out. Using a resistor with too low a resistance will allow too much current to flow through it and it will not be able to handle the power dissipated as heat.

The resistors used most often in projects are 1/4W resistors. Using 3.2V in and P = 0.250W, calculate I:
P = VI
I = P / V = 0.250W / 3.2V = 0.0781A = 78.1mA
What is R in this case?
R = VR / I = 3.2V / 78.1mA = 41.0 ohms

If R is anything less than 41.0 ohms, there will be too much current and too much power dissipated as heat.

Check the manufacturer’s specification sheet for the needed data when working with components if you do not already know. One trick you can use to find the needed data is to go to major electronics suppliers’ websites and look up the same or similar components and look at the specification sheets provided. Once you get into things a little more, application notes provided by manufacturers are also very handy. Other sources of information include technician level and university level textbooks as well as many books published on many topics in electronics and computers.

That thing called the InterWeb is good as well.