0% found this document useful (0 votes)
61 views5 pages

Project Source Code: //program To

This document contains the source code for a project that controls the speed of an AC motor using an Arduino. The code initializes an LCD display to show the motor status and speed. It reads the position of a switch and potentiometer to turn the motor on and off and adjust its speed, which is displayed on the LCD. When the switch is closed, an interrupt is attached to pulse the triac at a rate corresponding to the potentiometer reading to control motor speed.

Uploaded by

ya vika
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views5 pages

Project Source Code: //program To

This document contains the source code for a project that controls the speed of an AC motor using an Arduino. The code initializes an LCD display to show the motor status and speed. It reads the position of a switch and potentiometer to turn the motor on and off and adjust its speed, which is displayed on the LCD. When the switch is closed, an interrupt is attached to pulse the triac at a rate corresponding to the potentiometer reading to control motor speed.

Uploaded by

ya vika
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Project Source Code

###

//Program to

#include <LiquidCrystal.h>//import the LCD library

LiquidCrystal lcd(13, 12, 6, 5, 4, 3);// Pins used for RS,E,D4,D5,D6,D7

#define triacPulse 10

#define SW 7

int x=0;

void setup() {

Serial.begin(9600);

lcd.begin(16,2);//LCD 16x2 initialization

pinMode(2, INPUT);

digitalWrite(2, HIGH); // pull up

pinMode(triacPulse, OUTPUT);

pinMode(SW, INPUT);
digitalWrite(SW, HIGH);

lcd.setCursor(0,0); //Initially set the cursor position of LCD to 1st Columb 1st row.

lcd.print("Engineers Garage");//After initialising print data

lcd.setCursor(0,1); //Initially set the cursor position of LCD to 1st Columb 2nd row.

lcd.print(" "); //print blank to clear all the data on LCD

delay(3000);

lcd.setCursor(0,0);

lcd.print(" SPEED CONTROL ");

lcd.setCursor(0,1);

lcd.print(" AC MOTOR ");

delay(3000);

lcd.setCursor(0,1);

lcd.print(" ");

void loop() {
lcd.setCursor(0,0);

lcd.print(" AC MOTOR ");

// check for SW closed

if (!digitalRead(SW)) {

x=analogRead(A0);

// enable power

attachInterrupt(0, acon, FALLING);

lcd.setCursor(11,0);

lcd.print("ON ");

lcd.setCursor(6,1);

lcd.print((analogRead(A0) * 7) + 200);

} // end if

else if (digitalRead(SW)) {

detachInterrupt(0); // disable power


lcd.setCursor(11,0);

lcd.print("OFF ");

lcd.setCursor(0,1);

lcd.print(" ");

} // else

} // end loop

// begin ac int routine

// delay() will not work!

void acon()

delayMicroseconds((analogRead(A0) * 7) + 200); // read AD1

digitalWrite(triacPulse, HIGH);

delayMicroseconds(50);
// delay 50 uSec on output pulse to turn on triac

digitalWrite(triacPulse, LOW);

###

You might also like