User Tools

Site Tools


notes:notes:notes:notes:notes:notes:notes:c4eng:fall2022:projects:vcc0

BACKGROUND

SELECTION LOGIC

RELATIONAL OPERATORS

Operator Description Example
== Checks if the values are equal or not, If yes, condition is true (A == B)
!= Checks if the values are equal or not, If values are not equal, then condition is true (A != B)
> Checks if the value of left operand is greater than the value of right operand (A > B)
< Checks if the value of the left operand is less than the value of right operand (A < B)
>= Checks if the value of left operand is greater than or equal to the value of the right operand (A >= B)
Checks if the value of left operand is less than or equal to the value of the right operand (A ⇐ B)

WIRINGPI INSTALL

In order to navigate successfully throughout the wiringPi library in the command-line, a few key functions are going to be needed:

gpio readall: This allows view of the table that correlates to the pins and positions on the breadboard. It gives the pin number in terms of what the Pi reads and in terms of what code for the project reads. It allows tells whether the pin is in Input mode or Output mode.

gpio mode: This allows one to change the mode of specific pins from Input to Output and visa versa. Once the command is typed, it will ask for the desired pin number (found in the readall table) and the desired mode (In/Out).

gpio write: Once the desired pins have been hooked up on the breadboard and configured on the Pi, this function is used to switch between supplying voltage or not. Once typed, it will ask for the desired pin (which should already be configured) and a choice of 0(off) and 1(on).

ELECTRONICS

BREADBOARD

The breadboard is the device we will use to build our circuits:

The electrical layout of the breadboard is as follows:

Here's a good video overview of the functionality of a breadboard:

The purpose of the breadboard is to make quick electrical connections between components- like resistors, LEDs, capacitors, etc- so that you can test your circuit before permanently soldering it together. Breadboards have many small sockets on them, and some groups of sockets are electrically connected to each other. On the underside of the board there are many small metal strips which physically connect certain groups of sockets together and allow electricity to flow freely between them. These strips are probably not visible on the underside of your breadboard.

COMPONENTS

Breadboard

A breadboard consists of plastic block holding a matrix of electrical sockets of a size suitable for gripping thin connecting wire, component wires or the pins of transistors and integrated circuits. The sockets are connected inside the board (by metal clips), in rows of five sockets horizontally.

GPIO Expansion Board

The GPIO Expansion board connects to the pins of your pi via a ribbon cable. The GPIO expansion board is then fitted onto the breadboard making the functionality of the pins available to use on the breadboard.

220 ohm resistors x4

Resistors limit or regulate the flow of electrical current in an electronic circuit. Too much current going to the LED can cause the LED to burn out as LEDs will take as much current as you give them, but not without a price. Limiting the current to the LED bulb using a resistor ensures that we supply enough current to light the bulb without supplying too much current burning out the bulb.

Jumper leads

Jumper leads are wires used to connect to the load components (LEDs) to the GPIO BCM pins.

CIRCUIT

ONE LED

Here is a diagram for a circuit driving one LED, from one GPIO pin:

You are after a circuit that drives four LEDs, each one from a unique GPIO pin.

FOUR LED

You will want to identify 2 additional GPIO pins (The example program has BCM 17 and 18 already included to run as an output) and you can identify the wiringpi pin number/BCM number by using

yourpi:~$ gpio readall

This will give you what your machine has for GPIO's, what the BCM Pin number is, as well as what the wiringpi pin number is. Each LED will require a GPIO power jumper wire, a resistor, and a ground. You can either use a different ground pin for each or simply use one ground pin ran to the ground rail on either side of the breadboard then ground all LEDs to the ground rail. Arranging your LEDs in a straight line of 4 is ideal as you will have each binary digit represented in order from right to left.

SPECIFICATIONS

PI SETUP

NOTE: As of 20220908, is not working for the pi 400. See the section below for the pi 400 workaround.

First, we need to download the wiringPi library package:

yourpi:~$ wget https://project-downloads.drogon.net/wiringpi-latest.deb

Then, we need to install it:

yourpi:~$ sudo dpkg -i wiringpi-latest.deb

wiringPi on the pi400

For the pi400, we have to do a slightly different process, but will result in the needed functionality becoming available.

On the pi (doesn't matter where, although probably NOT in your repository; base of home directory works fine):

yourpi~$ git clone https://github.com/WiringPi/WiringPi.git

Then:

yourpi:~$ cd WiringPi
yourpi:~/WiringPi$ 

Finally, build and install it:

yourpi:~/WiringPi$ ./build

Provided there are no apparent errors, close out of that terminal and open a new one, then the gpio tool and related WiringPi functionality should now be available.

PROGRAM

Declare int cont = 0; int num_cont = 8:

Make sure to record wiring pi assignments into pin array. Ex: pin[0] = 0 pin[1] = 2 pin[2] = 3 pin[3] = 4

Remember to use if and else statements in while statement. Digital write goes after all if and else statements. Else uses LOW meaning off and if uses HIGH meaning on.

notes/notes/notes/notes/notes/notes/notes/c4eng/fall2022/projects/vcc0.txt · Last modified: 2022/09/14 17:14 by 127.0.0.1