The [Raspberry Pi](https://www.ampheo.com/c/raspberry-pi/raspberry-pi-boards) 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. ![ict-raspberrypi-as](https://hackmd.io/_uploads/Hkh4DDaXgx.jpg) **1. Set Up Your Raspberry Pi** **What You Need** * Raspberry Pi (any model, but [Pi 4](https://www.ampheo.com/search/Pi%204)/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: ![企业微信截图_20250616173411](https://hackmd.io/_uploads/HkzEHDTXgl.png) **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!") ``` 3. Click Run (or press F5). **B. Using Terminal (Command Line)** 1. Open Terminal. 2. Create a file: ``` bash nano hello.py ``` 3. Type the Python code, then save (Ctrl+O, Enter, Ctrl+X). 4. 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](https://www.onzuu.com/category/resistors). **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](https://www.ampheoelec.de/c/raspberry-pi/raspberry-pi-boards)** **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](https://www.ampheo.com/c/sensors) ([DHT11](https://www.ampheo.com/product/dht11-26836202), Ultrasonic, PIR). * Build a web server (Flask, Node.js). * Try robotics (using GPIO + motors).