Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 18

Table fan using

Arduino Nano and


Ir remote control
Group members:
1. Ahmad Haziq Mirza bin Muhamad Zulkifli
2. Ahmad Adib Ridhwan bin Alhisham
3. Ahmad Iqbal bin Hafizi
Student Information
Department: DKE
Class: Kyushu

Name Student ID

Ahmad Haziq Mirza bin Muhamad


F55-220-0001
Zulkifli

Ahmad Adib Ridhwan bin Alhisham F55-220-0003

Ahmad Iqbal bin Hafizi


F55-220-0004
Content

01 Introduction 05 Literature review

02 Problem Statement 06 Methodology

03 Objective 07 Project outcome

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

Step1 Step2 Step3


Navigate to Sketch -> Include
Follow the pin connection as Download the Arduino IDE. Library -> Manage Libraries,
in the picture. search IRremote then install it.

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; } } }

smallpotval = potval / 25; if(swing==0){ way=0; }


potangle = potval / 5.68333;
irangle = potangle + degree; if(c==1 && d==0 && e==0)
swingangle = potangle + degree; { angle=irangle; }
if(c==0 && d==1 && e==0)
Coding
switch (results.value) { case 0xFF02FD: //button >> digitalWrite(led[1], LOW);
case 0xFF6897: //button 0 degree+=10; digitalWrite(led[2], LOW);
state = 0; f=1; delay(200);
break; break; }
if (state == 2) {
case 0xFF30CF: //button 1 case 0xFFC23D: //button >|| analogWrite(enA, 200);
state = 1; f=2; digitalWrite(in1, HIGH);
break; break; digitalWrite(in2, LOW);
} digitalWrite(led[0], HIGH);
case 0xFF18E7: //button 2 if (state == 0) { digitalWrite(led[1], HIGH);
state = 2; digitalWrite(in1, LOW); digitalWrite(led[2], LOW);
break; digitalWrite(in2, LOW); delay(200);
for (int i = 0; i < 3; i++) { }
case 0xFF7A85: //button 3 digitalWrite(led[i], LOW); if (state == 3) {
state = 3; } analogWrite(enA, 250);
break; } digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
case 0xFF22DD: //button << if (state == 1) { digitalWrite(led[0], HIGH);
degree-=10; analogWrite(enA, 200); digitalWrite(led[1], HIGH);
f=1; digitalWrite(in1, HIGH); digitalWrite(led[2], HIGH);
break; digitalWrite(in2, LOW); delay(200);
digitalWrite(led[0], HIGH); }
Coding
Serial.print(" angle: "); Serial.print(" e: ");
Serial.print(angle); Serial.print(e);
Serial.print(" potangle: "); Serial.print(" f: ");
Serial.print(potangle); Serial.println(f);
Serial.print(" irangle: ");
Serial.print(irangle); }
Serial.print(" swingangle: ");
Serial.print(swingangle);
Serial.print(" way: ");
Serial.print(way);
Serial.print(" state: ");
Serial.print(state);
Serial.print(" swing: ");
Serial.print(swing);
Serial.print(" a: ");
Serial.print(a);
Serial.print(" b: ");
Serial.print(b);
Serial.print(" c: ");
Serial.print(c);
Serial.print(" d: ");
Serial.print(d);
07
Project outcome
Increase the comfortability of a person when doing something
at a table.
Project outcome
ありがとうございます。
Thank you!

You might also like