Raspberry Pi Python Programming Examples

Basic Input/Output and Calculations

This code demonstrates basic input/output operations and calculations in Python on a Raspberry Pi.

Area Calculation

This code calculates the area of different shapes based on user input.

Current Time and Sleep

This code displays the current time and sleeps for 10 seconds repeatedly.

Word Count in a File

This code reads a text file and counts the number of words in each line.

LED Control with Switches

This code controls two LEDs using two switches. When a switch is pressed, the corresponding LED glows for 3 seconds.

LED Blinking with Time Control

This code blinks an LED with on and off times specified in a text file.

Relay Control

This code turns a relay on for 10 seconds and then turns it off.

Camera Capture

This code captures an image using the Pi Camera and saves it with the current timestamp.

Web Server for LED Control

This code creates a web server using Flask to control an LED. Users can turn the LED on or off through a web interface.

Motion Detection with Email Alert

This code detects motion using a PIR sensor and sends an email alert when motion is detected.

Web Server for LED Control (Alternative)

This code provides an alternative implementation of the web server for LED control using Flask.