i am preparing a project named automatic vehicle speed limit controller. the reference link is https://youtu.be/r-BtrSnzwTg . the problem i am facing is that when i upload a code in arduino uno r3 listed below-
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// I²C LCD @ 0x27, 16×2
LiquidCrystal_I2C lcd(0x27, 16, 2);
// RF decoder pins D0–D3
const uint8_t dataPins[4] = {8, 9, 10, 11};
const unsigned long rxDebounce = 200; // ms
unsigned long lastRxTime = 0;
// Motor shield (M1) pins
const uint8_t in1Pin = 12;
const uint8_t in2Pin = 13;
const uint8_t pwmPin = 3; // ENA
// Potentiometer input
const uint8_t potPin = A0;
// Vehicle’s true max speed in km/h
const float MAX_SPEED_KMPH = 100.0;
// PWM limit (0–255)
uint8_t speedLimit = 255;
// Predefined limits in km/h for RF buttons
const float btnLimitKmph[4] = {20, 40, 60, 80};
// flag to show overspeed only once
bool overspeedNotified = false;
void setup() {
Serial.begin(9600);
for (auto p : dataPins) pinMode(p, INPUT);
pinMode(in1Pin, OUTPUT);
pinMode(in2Pin, OUTPUT);
pinMode(pwmPin, OUTPUT);
digitalWrite(in1Pin, HIGH); // forward
digitalWrite(in2Pin, LOW);
lcd.init();
lcd.backlight();
lcd.setCursor(2,0);
lcd.print("Speed Limit");
lcd.setCursor(3,1);
lcd.print("Controller");
delay(2000);
lcd.clear();
lcd.setCursor((16-15)/2, 0); // "Made By Pushkar" = 15 chars
lcd.print("Made By Pushkar");
lcd.setCursor((16-8)/2, 1); // "Saraswat" = 8 chars
lcd.print("Saraswat");
delay(2000);
lcd.clear();
lcd.setCursor((16-17)/2, 0); // "St. Dominic's Sr." = 17 chars
lcd.print("St.Dominic's Sr.");
lcd.setCursor((16-18)/2, 1); // "Sec. School Mathura" = 18 chars
lcd.print("Sec.School Mathura");
delay(2000);
}
void loop() {
// 1) RF buttons → set new speedLimit
int highCount = 0, btn = -1;
for (uint8_t i = 0; i < 4; i++) {
if (digitalRead(dataPins[i]) == HIGH) {
highCount++;
btn = i;
}
}
if (highCount == 1 && millis() - lastRxTime > rxDebounce) {
float limitK = btnLimitKmph[btn];
speedLimit = uint8_t((limitK / MAX_SPEED_KMPH) * 255.0f + 0.5f);
lastRxTime = millis();
overspeedNotified = false; // reset notification on new limit
}
// 2) Read pot → desired PWM
int raw = analogRead(potPin); // 0–1023
uint8_t pwmDesired = map(raw, 0, 1023, 0, 255); // 0–255
// 3) Clamp & detect overspeed
bool overspeed = false;
uint8_t pwmOut = pwmDesired;
if (pwmDesired > speedLimit) {
pwmOut = speedLimit;
overspeed = true;
}
analogWrite(pwmPin, pwmOut);
// 4) Compute speeds (km/h)
float currentSpeed = (pwmOut / 255.0f) * MAX_SPEED_KMPH;
float limitSpeed = (speedLimit / 255.0f) * MAX_SPEED_KMPH;
// 5) Show overspeed alert only once
if (overspeed && !overspeedNotified) {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Overspeeding!");
lcd.setCursor(0,1);
lcd.print("Reducing to ");
lcd.print(limitSpeed, 1);
lcd.print("km/h");
delay(1500);
overspeedNotified = true;
lcd.clear();
}
// 6) Always show current Speed & Limit
lcd.setCursor(0, 0);
lcd.print("Speed:");
lcd.print(currentSpeed, 1);
lcd.print("km/h ");
lcd.setCursor(0, 1);
lcd.print("Limit:");
lcd.print(limitSpeed, 1);
lcd.print("km/h ");
delay(300);
}
using this code the motor doesn't run at any time. it is still all time. i have doublechecked everything motor also. but when i upload below code-
#include <AFMotor.h>
AF_DCMotor motor4(4);
void setup() {
motor4.setSpeed(255);
motor4.run(FORWARD);
}
void loop() {
// do nothing—motor should spin continuously
}
the motor runs using this code. help me out by telling what is the issue with my project as i want to show it in a exhibition after 3 days.



