You are on page 1of 2

#include <Servo.

h>

#include <LiquidCrystal.h>

LiquidCrystal lcd(3, 13, 9, 10, 11, 12);

Servo ESC; // create servo object to control the ESC

float potValue; // value from the analog pin

float percentg=0;

void setup() {

// Attach the ESC on pin 9

ESC.attach(6,1000,2000); // (pin, min pulse width, max pulse width in microseconds)

lcd.begin(16, 2);

// Print a message to the LCD.

lcd.setCursor(0, 0);

lcd.print(" BLDC MOTOR ");

lcd.setCursor(0, 1);

lcd.print("SPEED CONTROLL");

delay(2000);

lcd.clear();

void loop() {

potValue = analogRead(A0); // reads the value of the potentiometer (value between 0 and 1023)

potValue = map(potValue, 0, 1023, 0, 180); // scale it to use it with the servo library (value between 0
and 180)

ESC.write(potValue); // Send the signal to the ESC


percentg = (potValue / 180)*100;

lcd.setCursor(0, 0);

lcd.print(" MOTOR SPEED :- ");

lcd.setCursor(4, 1);

lcd.print(" ");

lcd.setCursor(6, 1);

lcd.print(percentg);

delay(1000);

You might also like