RTUComputer ScienceYr 2023 · Sem 72023

Q15Internet of Things

Question

4 marks

Write a Python script to blink an LED using Raspberry Pi.

Answer

A Python script using the RPi.GPIO library controls the GPIO pins.

To blink an LED, we interface it with a GPIO pin on the Raspberry Pi. The Python script imports the RPi.GPIO library and the time module.

The script sets the pin mode to OUTPUT. Inside a loop, it sets the pin high (turning the LED on), pauses using time.sleep(), sets the pin low (turning the LED off), and pauses again. This cycle creates the blinking effect.

Back to Paper