Community Discussion · Policy

DIY Xiaomi Pengcheng-style low-speed running light for 50 yuan

Flight Control YouthFlight Control YouthAug 22026/08/02 83 views

Title: DIY Low-Speed Turning Light for 50 Yuan

A friend recommended low-speed turning lights, saying they automatically illuminate both sides when parking in narrow lanes at night, lighting up blind spots. I checked the news, and it's true—some car models activate them automatically when speed is below 10km/h, illuminating the road surface on both sides. Sounds like a low-cost but practical feature. Problem is, I don't have a car. But as an embedded engineer who deals with sensors and lights daily, I decided to replicate one using materials costing tens of yuan to experience what makes it good.

Conclusion first: Is it worth doing? If you like hands-on projects or want to do a science experiment for kids, this solution is completely feasible. Effect definitely won't match OEM car lights, but the idea is similar—use distance sensors to detect "obstacles" (like walls or pedestrians), simulating a "low-speed approach" scenario, automatically lighting up LEDs. The whole process takes about 2 hours, cost under 50 yuan.

What You Need to Prepare

Buy these items on Taobao or Pinduoduo, total price roughly 40-50 yuan:

1. Arduino Nano or compatible board (around ten yuan, basically a small computer that runs programs)

2. HC-SR04 Ultrasonic Sensor (a few yuan, looks like two little eyes, measures distance)

3. Two 5mm LEDs, white or yellow (cents each)

4. Two 220-ohm resistors (to protect LEDs)

5. One Breadboard (plastic board for plugging wires, no soldering needed)

6. Bundle of Dupont Wires (get a few male-to-female and male-to-male)

If you don't understand these terms, don't worry. I was clueless when I first touched a breadboard. I'll write clearly where to connect and plug in each step later.

Step 1: Plug Parts into Breadboard

Breadboards look like this: Rows of small holes in the middle, 5 holes in each row connected internally. Take the Arduino board, carefully plug it into the center channel of the breadboard, ensuring pins on both sides go into separate rows. Note orientation—USB port facing the board edge.

Pitfall 1: I plugged it in backwards the first time, couldn't download the program. Keep the chip text on the board facing up, USB port facing up towards you, and you won't go wrong.

After plugging in, insert the ultrasonic sensor on the other side of the breadboard, with the two circular "eyes" facing outward. Sensor has four pins: VCC, Trig, Echo, GND. Connect with Dupont wires:

  • VCC → Arduino 5V pin (power)
  • Trig → Arduino D9 pin (send signal)
  • Echo → Arduino D10 pin (receive signal)
  • GND → Arduino GND pin (ground)

LEDs have long and short legs. Long leg is positive. Connect it through a 220-ohm resistor to Arduino D3 pin; short leg connects to GND. Do the same for the other LED: positive to D5, negative to GND. How to connect the resistor? Plug one end into the hole in the same row as the LED's positive leg, and the other end into the hole where D3 is located.

Pitfall 2: Must series-connect the resistor, otherwise LED burns out. I skipped it the first time to save effort, and the LED smoked immediately, ruined.

Step 2: Write Code for Arduino

Connect Arduino board to computer via USB cable, open Arduino IDE (free software, search "Arduino download" on Baidu). If not installed, download latest version from official site, install and open.

Create new file, copy code below:

// Define pins
#define TRIG_PIN 9
#define ECHO_PIN 10
#define LED_LEFT 3
#define LED_RIGHT 5

void setup() {
  pinMode(TRIG_PIN, OUTPUT);
  pinMode(ECHO_PIN, INPUT);
  pinMode(LED_LEFT, OUTPUT);
  pinMode(LED_RIGHT, OUTPUT);
  Serial.begin(9600); // Open serial monitor for debugging
}

void loop() {
  // Send ultrasonic pulse
  digitalWrite(TRIG_PIN, LOW);
  delayMicroseconds(2);
  digitalWrite(TRIG_PIN, HIGH);
  delayMicroseconds(10);
  digitalWrite(TRIG_PIN, LOW);

  // Read echo time (microseconds)
  long duration = pulseIn(ECHO_PIN, HIGH);
  // Convert to distance (cm): Speed of sound 340m/s, divide by 2 for round trip
  float distance = duration * 0.034 / 2;

  // Simulate low-speed state: Use distance detection instead of car speed. When obstacle approaches (distance < 30cm), light up LED
  if (distance < 30 && distance > 0) {
    digitalWrite(LED_LEFT, HIGH);
    digitalWrite(LED_RIGHT, HIGH);
    Serial.println("Light On! Distance:");
    Serial.println(distance);
  } else {
    digitalWrite(LED_LEFT, LOW);
    digitalWrite(LED_RIGHT, LOW);
  }
  delay(200); // Detect every 0.2 seconds
}

Click the "Verify" button in toolbar (checkmark icon) to check for errors. If it shows "Compilation successful," click "Upload" (right arrow). Program flashes onto the board. Board blinks a few times during upload; wait a few seconds until "Upload successful" appears.

Pitfall 3: If error "Port not found" occurs during upload, go to "Tools -> Port" and select the correct COM port. On Windows, usually COM3 or COM4. If still not working, check if USB driver is installed, or swap data cable (some cables only charge, don't transmit data).

Step 3: Test Your Low-Speed Turning Light

Power the board via USB (power bank works too). Honestly, slowly move your hand in front of the ultrasonic sensor. When palm distance is less than 30cm, both LEDs should light up simultaneously. Remove hand, lights off. If lights don't turn on, check wiring and ensure pin numbers in code match.

Pitfall 4: If there's an obstacle directly in front of the sensor and distance is too close (e.g., <2cm), HC-SR04 measures inaccurately, lights might not turn on. This is normal; actual car low-speed turning lights don't activate when pressed against walls either. Adjust threshold to above 30cm.

This Device vs. Real Low-Speed Turning Lights

OEM lights trigger via vehicle speed sensors; we simulate using distance sensors—when obstacles approach, it equates to vehicle approaching at low speed, thus lighting LEDs. Although trigger methods differ, core logic is identical: "Automatically illuminate blind spots under specific conditions." If interested, you can change threshold to 50cm, or add buzzer for sound alerts, entirely up to your creativity.

0 replies

?
Ctrl + Enter to reply
No replies yet — be the first to share your thoughts