Try   HackMD

The Raspberry Pi is a versatile mini-computer that supports multiple programming languages. Here’s how to start coding on it, from setup to running your first program.

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

1. Set Up Your Raspberry Pi
What You Need

  • Raspberry Pi (any model, but Pi 4/5 recommended).
  • MicroSD card (16GB+) with Raspberry Pi OS (previously called Raspbian).
  • Keyboard, mouse, and monitor (or SSH for headless setup).

Install Raspberry Pi OS

  1. Download Raspberry Pi Imager from raspberrypi.com.
  2. Flash the OS to your MicroSD card.
  3. Insert the card into the Pi, power it on, and complete setup.

2. Choose a Programming Language
The Pi supports almost any language, but the easiest for beginners are:

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

3. Write & Run Your First Program (Python Example)
A. Using the Thonny IDE (Pre-installed)

  1. Open Thonny from the Programming menu.
  2. Type:
python
print("Hello, Raspberry Pi!")  
  1. Click Run (or press F5).

B. Using Terminal (Command Line)

  1. Open Terminal.
  2. Create a file:
bash
nano hello.py  
  1. Type the Python code, then save (Ctrl+O, Enter, Ctrl+X).
  2. Run it:
bash
python3 hello.py  

4. Coding for GPIO (Hardware Control)
Want to blink an LED? Here’s how:

Circuit Setup

  • Connect LED+ to GPIO17 (Pin 11).
  • Connect LED- to GND (Pin 9) with a 220Ω resistor.

Python Code (Using RPi.GPIO Library)

python
import RPi.GPIO as GPIO  
import time  

GPIO.setmode(GPIO.BCM)  
GPIO.setup(17, GPIO.OUT)  

try:  
    while True:  
        GPIO.output(17, GPIO.HIGH)  # LED ON  
        time.sleep(1)  
        GPIO.output(17, GPIO.LOW)   # LED OFF  
        time.sleep(1)  
except KeyboardInterrupt:  
    GPIO.cleanup()  

Run with:

bash
python3 blink.py  

5. Other Ways to Code on Raspberry Pi
A. Remote Development (VS Code + SSH)

  1. Enable SSH on Pi (sudo raspi-config → Interfacing Options → SSH).
  2. Install VS Code on your PC + "Remote SSH" extension.
  3. Connect to your Pi and edit files directly.

B. Web-Based IDEs
Jupyter Notebook (for Python):

bash
pip3 install jupyterlab  
jupyter-lab --ip=0.0.0.0  

Access at http://<Pi-IP>:8888.

6. Next Steps

  • Explore sensors (DHT11, Ultrasonic, PIR).
  • Build a web server (Flask, Node.js).
  • Try robotics (using GPIO + motors).