Professional Documents
Culture Documents
Present Miniprojek
Present Miniprojek
Name Student ID
04 Project Scope
Introduction
The table fan uses a microcontroller to control the
outputs based on its inputs. The microcontroller
receive inputs from a remote control, button and a
knob. The settings that can be controlled are the fan
speed, fan automatic swing and fan angle.
02
Problem Statement
The problem that this study addresses is a short range of
controlling a table fan which may be a problem if one is not in
the range where he could reach the button on the fan. This
project overcome the problem by allowing the table fan to be
controlled over a longer distance.
03
Objective
• To develop the project coding
• To build the project prototype
• To demonstrate a fully functional prototype
04
Project Scope
This project is suitable for indoor usage because the prototype
is hard to be carried around. The prototype is big in size which
may cause inconvenient for outdoor usage.
05
Literature review
This project is about controlling the fan by an IR receiver and a
button. The reason why we chose this project was the Arduino
Uno is small enough to be put in a plastic cup and support to
connect difference modules and component, so we use it to
make the Mini fan to place it on a table.
06
Methodology
Methodology
Step4 Step5
Copy the code shared on the Try to press the button or IR
Arduino IDE then upload it to remote to make sure it can work
Arduino Uno. properly.
Pin connection
Coding
#include <Servo.h> int servopin = 10; pinMode(in2, OUTPUT);
#include <IRremote.h> int potpin = A0; pinMode(btpin, INPUT);
Servo servo; int enA = 5; pinMode(potpin, INPUT);
int swingangle; int in1 = 6; servo.attach(servopin, 500, 3600); //
int potangle; int in2 = 7; servo at pin 10 of arduino
int irangle; int led[3] = {2, 3, 4}; servo.write(90);// initial angle at the
int angle; IRrecv irrecv(irpin); start of program
int degree; decode_results results; digitalWrite(in1, LOW);
int swing; int a,b,c,d,e,f; digitalWrite(in2, LOW);
int state; Serial.println("Enabling IRin");
int way; void setup() { irrecv.enableIRIn(); // Start the receiver
int btval; Serial.begin(9600); Serial.println("Enabled IRin");
int oldbtval = 0; for (int i = 0; i < 3; i++) { }
int potval; pinMode(led[i], OUTPUT);
int oldpotval; Serial.print(i);
int smallpotval; }
int oldsmallpotval; pinMode(enA, OUTPUT);//0-255 value
int btpin = 8; PWM
int irpin = 9; pinMode(in1, OUTPUT);
Coding
void loop() { if(f==1){ c=1; d=0; e=0; swing=0;} { angle=potangle;}
potval = analogRead(potpin); if(smallpotval != oldsmallpotval) { c=0; d=1; if(c==0 && d==0 && e==1)
btval = digitalRead(btpin); e=0; swing=0; f=0;} { angle=swingangle; }
oldsmallpotval=smallpotval;
if(btval != oldbtval) { a++; } if(swing==1 || f==2){ c=0; d=0; e=1; if(angle>190 || irangle>190 || potangle>190 ||
if(a==1 && btval==1){ b++; } swing=1;} swingangle>190){ angle=179; irangle=179;
if(b>5 || b==0){ a=0; } potangle=179; swingangle=179;}
if(b==6){ swing++; a=0; b=0;} if(swing==1){ if(angle<-10 || irangle<-10 || potangle<-10 ||
if(a==2 && b==1){ state++; a=0; b=0;} if(potangle<180 && way==0){ degree+=5;} swingangle<-10){ angle=1; irangle=1;
if(btval==0){a=0; b=0;} if(angle==1){ way=1; } potangle=1; swingangle=1; }
if(swing==1 && b==5){ e=0; f=0; } if(angle==179){ way=2; } servo.write(angle);
if(way==1){ degree+=5; }
oldbtval=btval; if(way==2){ degree-=5; } if (irrecv.decode(&results)) {
//if(degree>179){ degree=174; } Serial.println(results.value, HEX);
if(state>3){ state=0; } //if(degree<1){ degree=6; } irrecv.resume();
if(swing>1){ swing=0; } } }