Hardware & IoTLesson 104Free preview
RasPi RGB LED WebSocket
This lesson is part of Node.js · All levels
Summary
This lesson developed the IoT project into a color-modified RGB LED from a browser via WebSocket. You'll understand how to combine three channels of red, green, and blue to produce millions of colors, and then control them through JSON messages. The project combines electronics, GPIO, and real-time communication in one application.
Key points
- RGB LEDs have three anode/cathode (R, G, B); a combination of 0/1 or PWM values produces color.
- Each channel is connected to a separate GPIO pin via a resistor (e.g. GPIO 17, 27, 22).
- WebSocket receives a command containing {r, g, b} from a browser client.
- The base colors are (1,0,0) red, (0,1,0) green, (0,0,1) blue; (1,1,1) white.
- For smooth colors use PWM.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.