Project Source Code: //program To

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 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