Node.js Raspberry Pi GPIO Blinking LED
Here is a simple, complete, and beginner-friendly guide for Node.js Raspberry Pi GPIO Blinking LED.
๐ด Node.js Raspberry Pi โ Blinking LED (GPIO Output)
Blinking an LED is the first step in learning GPIO programming on Raspberry Pi.
With Node.js, it becomes very easy and fun!
โ 1. What You Need
Hardware:
1 ร Raspberry Pi (any model with GPIO)
1 ร LED (any color)
1 ร 330ฮฉ resistor
Jumper wires
Breadboard (optional)
๐ 2. Wiring the LED
Connect as follows:
GPIO17 (Pin 11) โ Resistor โ LED Anode (+)
LED Cathode (โ) โ Ground (Pin 6)
The long leg of the LED = positive (anode)
๐ฆ 3. Install GPIO Library
Use the onoff package:
๐ก 4. Create the Blink Script
Create a file:
Paste this code:
โถ 5. Run the Script
Because GPIO needs root access:
You should see the LED blink every 500ms.
๐งช Optional: Change Blink Speed
Fast blink (100ms):
โ Important Safety Notes
Raspberry Pi GPIO pins output 3.3V only, never 5V.
Always use a resistor to prevent LED burn-out and GPIO damage.
Always stop your script before unplugging wires.
