2 – Pin Initialization and Assignment

The Proviz Language needs pin information to create your sensor application. Every sensor and board has pin headers to communicate with other devices. If you know what a pin header is, you may skip to Part 1.b. Otherwise, proceed to Part 1.a where we will explain what a pin header is and how it is used.


Part 1.a

A pin header (often abbreviated as PH, or simply header) is a type of electrical connector. It consists of one or more rows of male pins typically spaced 2.54 millimetres (0.1 in) apart, but 5.08 millimetres (0.2 in), 5.00 millimetres (0.197 in), 3.96 millimetres (0.156 in), 2.00 millimetres (0.079 in), 1.27 millimetres (0.05 in) or 1.00 millimetre (0.04 in) are common as well.[1] The distance between pins is commonly referred as pitch in the electronic community.

In the past, a pin header was known as a Berg connector, but the term fell out of favor because pin headers are manufactured by many companies.

Figure 1 and Figure 2 show common pin headers.

Figure 1

Figure 2

 

This brief overview of pin headers, Figure 1 and Figure 2 were taken from a wikipedia.org page. You may access it here.


In order to create an IoT application, pin headers have to be initialized and assigned to IoT boards. IoT boards can have several pin headers; they can be analog pin headers or digital pin headers. There are a few other types of pin headers, but Proviz only offers support for these so far.

Pin initialization and assignment should be placed before Pinconfiguration and main function.

Let’s talk about how to initialize and assign a pin.

Pin <pin-variable-name> = new <pin-type>(<pin-number>);

The <,> tags represent input words of your choice.

The above code snippet represents proper pin initialization grammar.

Pin initialization must begin with the reserve word, “Pin”. When our compiler reads “Pin” it understands that a pin is being initialized and assigned. Next, give this pin a unique name.

After “=” sign, you must specify which pin type you will use.

Potential candidates for pin types (we do intend on extending this list):

  • AnalogPin
  • DigitalPin

After setting the pin type, you will give the pin a number. Pin number should be an integer value and this number should be assigned based on your respective IoT board pin number limits.

Let’s talk about pin number limits.

Every IoT board has its limits, one of them being the number of pin headers that it can hold. Don’t worry if you are confused, we are going to explain this to you.

Let’s assume that we have raspberry Pi 3 Model B.

This is a picture of Raspberry Pi 3 Model B

Raspberry Pi 3 Model B Figure 3

As you can see at top of this board, there are pin headers. These pin headers can be called GPIO (General Purpose INPUT/OUTPUT). You can see them in Figure 4.

Figure 4

There is a layout for pin headers and every pin header has different roles; some of them might be 5V or 3.3V and some of them might be ground. If you mix up these pin headers, you may fry your sensors or even your IoT board. Therefore, it is good practice to find a proper image or documentation which explains your pin header’s functionality. For example pin header functionality for Raspberry Pi 3 Model B can be reached through this link.

We strongly advise you to refer to official documentation to protect your IoT boards and sensors.

As you can see now, if your board has 10 digital pin headers, you may give a 1 to 10 integer value in the pin-number field. Note: you should double check that your pin is connected as you program it in Panther language.

Leave a reply

Your email address will not be published.

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>