0% found this document useful (0 votes)
10 views

C Programming

The document provides instructions to install an operating system on a Raspberry Pi by formatting an SD card, downloading an image file, writing the image to the SD card using software like Win32DiskImager, and then booting up the Raspberry Pi. It also describes how to install the GPIO Zero library in Python to access GPIO pins and use them to blink an LED connected to a pin or adjust the LED's brightness using pulse-width modulation.

Uploaded by

Anusree Kalkaran
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

C Programming

The document provides instructions to install an operating system on a Raspberry Pi by formatting an SD card, downloading an image file, writing the image to the SD card using software like Win32DiskImager, and then booting up the Raspberry Pi. It also describes how to install the GPIO Zero library in Python to access GPIO pins and use them to blink an LED connected to a pin or adjust the LED's brightness using pulse-width modulation.

Uploaded by

Anusree Kalkaran
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Cycle-2

7. lnstalllng OS on Raspberry Pi

a) Installation using Pilmager

b) Installation using image file

• Downloading an Image

• Writing the image to an SD card

• using Linux

• using Windows

• Booting up

Aim: To install OS on Raspberry Pi.

Software Required:

1. Raspberry Pi

2. Internet

Procedure:

FORMAT THE SD CARD:

Locate your SD card drive, in Windows Explorer, and secondary-click the mouse to bring

up the context-sensitive menu. From the menu select Formate .... Ensure that the option FAT32

IDefualt) is selected and click start.

IIWC.- (1>.)

--....
o,....
,___
._....DrMc..

c.. tttJll1Jll)lll
c.., !O!·MU1!>28

--
c--...
t"t."llUl0-3'1
9-4n'lU~'

Selecti ng an SD card to format

B.Tech 1" Vear I ECE 30 JNTUHCEH


A few moments later you will see a confirmation that the format has been completed and you SD
card is now ready for the next stage.

r- - - 1

--
121...--,
c,.y,~ ~ MS-OOS sa,·k.C) ~

_.. ,c~ J

Formatting the SD card

USING WIN32DISKIMAGER:

Having plugged in your SD card, (re)start Win32Diskimager. Choose the drive you want to copy the
image to (in my case F:).

Choose the drive with your SD card to write the OS image on

Then click on the folder icon and choose the unzipped .img file from earlier that you want to put

on the SD card. Then click Write, to write the Operating system on the card from the .img file.

, Win32 D isk lmager • • l11C..JAli©I 1;"'2::zl


Image Ale Oevtoe
-- ~ ([F;\J ·I
ID MDS Hash:
Progress
I

Cancel
l Read
l Write
r Exit

...

Write OS image from .img file to SD card

You will then be asked t o confirm. Check carefully that you are writing to the correct device and if

so , click Yes.

~ Win32 D isk Image,- f I'


Jmoge A le Device
S-wheezy· respbia o/2012-07- 15--wheezy-ra spbia n.img ~ [F:\] •
[J MOS Hash:
Progress

[ cancel- ]! Raad
W rite d a ta i n 1mage File· t o "Device'
IL ([~~- E><l_t__,,.
~ .:i

B.Tech 1" Vear I ECE 31 JNTUHCEH


Check device and confinn

The progress bar will show you how far it's got.

Ir~~Confirm overwrite- I-
I MU
=::!!!Ill

& Writing to a physical device can corrupt the device.


Are you sure you want to continue?

_~j [_N
~[_ Yes _o_!

Progress indicator

When it's finished it looks like this.

~ Win32 Disk lmager


I Image Rle
"iiiii' ~
5- wheezy- raspblan/ 20 12- 07-15--w heezy-raspbtan .lmg ~
• -tj/
Device
I [F:\] •

l!:) MDS H<tsh:


Progress
r: - :::::'if 38%

I cance1 I Re<td Wrrte

9.72763M8/s

Finished

Then you can eject the card reader and remove the SD card. Then you can try it out in your

Raspberry Pi

~ -Win32 Disk Imager !c.lSl-f3-i"


lm<tge Ale Device
.5-wheezy-raspb,an/ 2012-07-15-wheezy-raspb,an.img ~ • [F:\] •

□ MDS Ha,;h·
Progress

- cancel [ R~L w~ l~_Elol


_ _.,,.
:Oo ne'.'111

B.Tech 1st Year I ECE 32 JNTUHCEH


8. Accessing GPIO pins using Python

a) Installing GPIO Zero library.

First, update your repositories list: sudo apt update

Then install the package for Python 3: sudo apt install python3-gpiozero

Aim: To install GPIO Zero library.

Software Required:

1. Web Browser

2. Internet

Procedure:

Install from repository:

If the package exists in the raspbian repository is can be installed using apt-get.

First you need to update the available package versions.

sudo apt-get update

Then attempt to install the Rpi.GPIO package:

sudo apt-get install rpi.gpio

If it isn't already installed it will be installed.If it is already installed it will be upgraded if a

newer version is available.

Result: Hence, the GPIO Zero library is installed.

B.Tech 1" Vear I ECE 33 JNTUHCEH


b) Blinking an LED connected to one of the GPIO pin

Aim: To blink an LED connected to one of the GPIO pin.

Software Required:

1. Raspberry Pi

2. Internet

Program:

import RPi.GPIO as GPIO

import time led Pin= 11 # GPIO 17

delay = 1 # ls loopCnt = 100

def main():

for i in range(l0):

print("LED turning on.")

GPIO.output(ledPin, GPIO.HIGH)

time.sleep(0.5)

print("LED turning off.")

GPIO.output(ledPin, GPIO.LOW)

time.sleep(0.5)

def setup():

GPIO.setmode(GPIO.BOARD)

GPIO.setup(ledPin, GPIO.OUT) # initialize GPIO pin as OUTPUT pin

GPIO,output(ledPin, GPIO.LOW)

if _name_== '_ main_':

setup()

main()

GPIO.cleanup() # free up the

B.Tech 1" Vear I ECE 34 JNTUHCEH


Output:

LED turning on.

LED turning off.

LED turning on.

LED turning off.

LED turning on.

LED turning off.

LED turning on.

LED turning off.

LED turning on.

LED turning off.

>>>

Result: Hence, GPIO pins are accessed to blink an LEO.

B.Tech l"Year I ECE 35 JNTUHCEH


c) Adjusting the brightness of an LED

Adjust the brightness of an LED (Oto 100, where 100 means maximum brightness)

using the in-built PWM wavelength.

Aim: To adjust the brightness of an LED.

Software Required :

1. Raspberry Pi

2. Internet

Program:

import RPi.GPIO as GPIO

import time

GPIO.setmode(GPIO.BOARD)

GPIO.setup(ll, GPIO.OUT)

p = GPIO.PWM(ll, 100)

p.start(0)

while True:

for x in range (0, 100, 1):

p.ChangeDutyCycle(x)

time.sleep(0.1)

for x in range (100, 0, -1):

p.ChangeDutyCycle(x)

time.sleep(0.1)

Output:

LED turning on.

LED turning off.

LED turning on.

LED turning off.

Result: Hence, GPIO pins are accessed to adjust the brightness of an LED.

B.Tech 1" Vear I ECE 36 JNTUHCEH

You might also like