🌊
课程 5 · 年级 13+
Analog and PWM: smooth light and servos
📖 课程
──▶
🎯 测验——选择翻译
──▶
✅ 本课已完成
A digital pin only knows on/off. How to dim smoothly? PWM: the pin blinks 500× per second, analogWrite(9, 128) = half brightness — the eye sees "smooth". Works on ~ pins (3,5,6,9,10,11). Servo: a motor turning to an angle 0–180° — servo.write(90). For shutters, camera pans, valves. The Servo.h library is built in.
- ●analogRead 0–1023 ↔ analogWrite 0–255: brightness = map(value, 0,1023, 0,255)
- ●Servos need separate power — a pin can’t supply enough current
- ●RGB LED = 3 LEDs in one body: 3 PWM pins = 16 million colours
🌊 The dimmer in your flat works by the same PWM principle — rapid on/off. Arduino just lets you play with what already lives inside your walls.