Professional Documents
Culture Documents
h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
void setup(){
Serial.begin(9600);// initialize serial communication at 9600 bits per second:
pinMode(potentiometer, INPUT);
pinMode(bt_F, INPUT_PULLUP);
pinMode(bt_S, INPUT_PULLUP);
pinMode(bt_B, INPUT_PULLUP);
pinMode(M1_Ena, OUTPUT);
pinMode(M1_in1, OUTPUT);
pinMode(M1_in2, OUTPUT);
lcd.begin(16,2);
lcd.setCursor(0,0);
lcd.print(" WELCOME To My ");
lcd.setCursor(0,1);
lcd.print("YouTube Channel");
delay(2000); // Waiting for a while
lcd.clear();
}
void loop(){
read_ADC = analogRead(potentiometer);
duty_cycle = map(read_ADC, 0, 1023, 0, 255);
duty_cycle_lcd = map(read_ADC, 0, 1023, 0, 100);
analogWrite(M1_Ena, duty_cycle);
lcd.setCursor(0,0);
lcd.print("Duty Cycle: ");
lcd.print(duty_cycle_lcd);
lcd.print("% ");
lcd.setCursor(0,1);
delay(50);
}