Sunday, December 11, 2016

Bright your LED with Raspberry PI

In Last blog i setup Raspberry PI, Initially i planned to not write blog for this example as internet already provided lot of examples and tutorial for flashing LED with Raspberry PI. but during my experience to test with PI4J i tried to explain things in my way.

This will be step by step tutorial starting with connecting the cables then some explanations and writing code in PI4J.

The Raspberry Pi is single board computer which is very good for prototyping and it has 40 pins that can be configured for General Purpose I/O (GPIO) and more.

First fit T-shaped Cobbler breakout board via a ribbon cable on breadboard. This is easier and safer than working directly on Raspberry Pi.(Like showed in Pic on left side)

Pin Numbering
Due to Pin numbering issue i was not able to run my sample at first so i have to learn more.
Pi4J is based on a project called WiringPi, which is a set of native libraries that provide access to the RPi’s GPIO ports. The labeled name on cobbler is different then the name used by PI4J, The pin numbers and their mapping to the actual pins on the RPi header are given in the picture below. So refer below for running for your samples.
For basic concept i will recommend following link

The breadboard is a way of connecting electronic components to each other without having to solder them together. They are often used to test a circuit design before creating a Printed Circuit Board (PCB).
The holes on the breadboard are connected in a pattern.
When you pick up the LED, you will notice that one leg is longer than the other. The longer leg (known as the ‘anode’), is always connected to the positive supply of the circuit. The shorter leg (known as the ‘cathode’) is connected to the negative side of the power supply, known as ‘ground’.
You must ALWAYS use resistors to connect LEDs up to the GPIO pins of the Raspberry Pi. The Raspberry Pi can only supply a small current (about 60mA). The LEDs will want to draw more, and if allowed to they will burn out the Raspberry Pi. Therefore putting the resistors in the circuit will ensure that only this small current will flow and the Pi will not be damaged.

Building Circuit
The circuit consists of a power supply (the Pi), an LED that lights when the power is applied, and a resistor to limit the current that can flow through the circuit.
You will be using one of the ‘ground’ (GND) pins to act like the ‘negative’ or 0 volt ends of a battery. The ‘positive’ end of the battery will be provided by a GPIO pin. 
GPIO pin 0 --> Jumper one leg
Jumper Second leg --> long leg of LED(same column)
Short leg of LED --> 330Ω resistor --> Ground.

Find below picture

Now you can run pi4j example, follow below link

No comments: