C Programming
C Programming
7. lnstalllng OS on Raspberry Pi
• Downloading an Image
• using Linux
• using Windows
• Booting up
Software Required:
1. Raspberry Pi
2. Internet
Procedure:
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
IIWC.- (1>.)
--....
o,....
,___
._....DrMc..
c.. tttJll1Jll)lll
c.., !O!·MU1!>28
--
c--...
t"t."llUl0-3'1
9-4n'lU~'
r- - - 1
--
121...--,
c,.y,~ ~ MS-OOS sa,·k.C) ~
_.. ,c~ J
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:).
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.
Cancel
l Read
l Write
r Exit
...
You will then be asked t o confirm. Check carefully that you are writing to the correct device and if
so , click Yes.
[ cancel- ]! Raad
W rite d a ta i n 1mage File· t o "Device'
IL ([~~- E><l_t__,,.
~ .:i
The progress bar will show you how far it's got.
Ir~~Confirm overwrite- I-
I MU
=::!!!Ill
_~j [_N
~[_ Yes _o_!
Progress indicator
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
□ MDS Ha,;h·
Progress
Then install the package for Python 3: sudo apt install python3-gpiozero
Software Required:
1. Web Browser
2. Internet
Procedure:
If the package exists in the raspbian repository is can be installed using apt-get.
Software Required:
1. Raspberry Pi
2. Internet
Program:
def main():
for i in range(l0):
GPIO.output(ledPin, GPIO.HIGH)
time.sleep(0.5)
GPIO.output(ledPin, GPIO.LOW)
time.sleep(0.5)
def setup():
GPIO.setmode(GPIO.BOARD)
GPIO,output(ledPin, GPIO.LOW)
setup()
main()
>>>
Adjust the brightness of an LED (Oto 100, where 100 means maximum brightness)
Software Required :
1. Raspberry Pi
2. Internet
Program:
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(ll, GPIO.OUT)
p = GPIO.PWM(ll, 100)
p.start(0)
while True:
p.ChangeDutyCycle(x)
time.sleep(0.1)
p.ChangeDutyCycle(x)
time.sleep(0.1)
Output:
Result: Hence, GPIO pins are accessed to adjust the brightness of an LED.