Hardware & IoTLesson 99Free preview
RasPi GPIO Introduction
This lesson is part of Node.js · All levels
Summary
This lesson introduces GPIO programming from Node.js, specifically with the onoff or rpi-gpio library. You'll learn to set the pin direction, write the HIGH/LOW values, and read the status of the button. This foundation became the capital for all the sensor and actuator projects on Raspberry Pi.
Key points
- Install the GPIO library as onoff.
- New Gpio(pin, direction) makes the object pin; 'out' to write, 'in' to read.
- Pin.write(1/0) turn on/off; pin.read() read the value (0/1).
- It is mandatory to call unexport() when finished so that the pins are released back into the system.
- Use a pull-up/pull-down resistor to keep the input from floating.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.