Patience's Project
Patience's Project
Patience's Project
Title of the project: Design and implementation of illumination control with precision
using Arduino with Bluetooth
―I do hereby declare that this project submitted in partial fulfillment of the requirement for
the Advanced Diploma in Electrical Technology at Muhabura Integrated Polytechnic
College, is my original work and has not previously been submitted elsewhere. Also, I do
declare that a complete list of references is provided indicating all the sources of information
quoted or cited.
……………………………………………
i
b. Authority to submit the project
In my capacity as supervisor, I hereby authorize the student to submit the project to the department
ready for presentation
………………………………………………………….
ii
DEDICATION
iii
ACKNOWLEDGEMENT
Let me take this opportunity to thank Almighty God for this achievement and people who
helped me.
I am going to start by thanking my supervisor Eng. Marie Grâce BERWA for assisting me in
conducting this project all advice she gave helped me and thanks to all Muhabura Integrated
Polytechnic College Staff for all effort done to increase my knowledge.
I would like to thank particularly my family for their financial contribution for carrying out
my studies. I would like to appreciate all colleagues of my class, who had helped me in
whatever I was doing in Muhabura Integrated Polytechnic College and also all effort
provided by every one of you, according to his/her capacities for helping me, to achieve this
work.
iv
ABSTRACT
This project presents the development of illumination control with precision using a Triac
control circuitry. Lighting is the biggest use of electricity, extending worldwide and to almost
everyone. Lighting is crucial to activities after sunset, indoors activities, experimentation
convenience and so on. The vast use of lighting calls upon the need to control the amount of
illumination according to preference or activity. Too much or too little illumination has seen
the increase into various eye conditions and headaches. Also adequate lighting ensures safety
and efficient operations. In this project I will design and implement an illumination control
system based on Arduino and Bluetooth. This system can be handy for multipurpose halls,
experimentations, workplaces, and homes. I will use proteus to simulate my circuit, visual
data collection of illumination in relation to inputs. The Arduino program will be key in
linking inputs to triac. At the end of my project after designing, building the prototype; I
tested the system and I could be able to control the illumination simply by using my
Smartphone.
v
TABLE OF CONTENTS
DEDICATION.............................................................................................................................. iii
ACKNOWLEDGEMENT ........................................................................................................... iv
ABSTRACT ................................................................................................................................... v
1.3. Objectives............................................................................................................................ 2
Households ..................................................................................................................................... 2
Entertainment................................................................................................................................. 2
2.0. INTRODUCTION.............................................................................................................. 4
vi
2.4. Cables and Connectors ...................................................................................................... 8
vii
5.0 Summary ............................................................................................................................ 26
APPENDIX .................................................................................................................................. 28
viii
LIST OF SYMBOLS, AND ABBREVIATIONS/ACRONYMS
ix
LIST OF TABLES
x
LIST OF FIGURES
xi
CHAPTER ONE: GENERAL INTRODUCTION
1
1.3. Objectives
1.3.1. Main objective
The main objective is to design and implement a lamp illumination control with precision
using Arduino.
Households
At home people need to vary illumination level according to their preferences, work,
or physical conditions. A home shelters a number of people has several rooms hence
plenty of light bulbs. People may move out and a different family moves in.
Working places
OSHA has put forth the necessary standards pertaining to workplaces. Control of
illumination levels is crucial to match the work being done. An office clerk may
require particular lighting needs that help their vision.
Entertainment
Illumination control is not only a scientific interest but also an art interest. With the
help of an automated illumination control, one can develop an artful display for
performance stages, bars, and more.
2
1.6. Organization of study
Chapter 1 is introduction and consists of 6 parts. They are background to study, problem
statement, project objectives, scope of study, significance of the study and the organization of
the study.
Chapter 2 is literature review. It emphasizes on defining main terms and concepts pertaining
to the study. It will talk about similar projects.
Chapter 3 is research methodology. I will discuss ways and techniques that I used to make me
researches. They are methods used to collect the data.
Chapter 4 is presentation and analysis of Results of the data collected during research.
Chapter 5 is the summary, conclusion and Recommendations of my research.
3
CHAPTER TWO: LITERATURE REVIEW
2.0. INTRODUCTION
This chapter discussed on other related or similar works, and then defined related terms and
ideas on the topic. It discusses basic concepts and the basic components used and their
function.
2.1. Resistors
If there wasn‘t such a thing as resistance, the subject of electronics wouldn‘t exist; only
infinite currents would flow and voltages wouldn‘t exist either! We need to reduce the flow
of current if we are to make current do something useful for us. Components that resist the
flow of current are called resistors, and they are said to have a resistance which is measured
in ohms (), named after Georg Ohm, who formulated the law (also named after him) by
which the voltage and current through a conductor are related (Scherz, 2000).
Some substances, such as carbon, conduct electricity fairly well but not really well. The
conductivity can be changed by adding impurities like clay to a carbon paste, or by winding a
thin wire into a coil. Electrical components made in this way are called resistors. They are
important in electronic circuits because they allow for the control of current flow. Resistors
can be manufactured to have exact characteristics. Imagine telling each person in the line that
they must pass a certain number of balls per minute. This is analogous to creating a resistor
with a certain value of electrical resistance. The better a resistor conducts, the lower its
resistance; the worse it conducts, higher the resistance (Gibilsco, 2002).
Resistors are manufactured in several sizes and varieties. They come in ‗fixed‘ and ‗variable‘
versions. The most commonly used are the ‗fixed‘ carbon ‗E12‘ range. This is a range of
values which has 12 resistor values which repeat: 10, 12, 15, 18, 22, 27, 33, 39, 47, 56, 68, 82
and then: 100, 120, 150, 180, 220, 270, 330, 390, 470, 560, 680, 820 and then: 1000, 1200,
1500, 1800, 2200, 2700, 3300, 3900, 4700, 5600, 6800, 8200, etc.
Nowadays, circuits often carry very little power and so the resistors can, and are, made in
very small physical sizes. The higher the resistance value of a resistor, the less current will
flow through it when a voltage is placed across it. As it can be difficult to see printing on
small resistors clustered together on a circuit board and surrounded by other larger
components, the resistor values are not written on the resistors, instead, the resistors are
color-coded. The unit of measurement for resistors is the ‗ohm‘ which has a very small size.
4
Most resistors which you encounter will be in the range 100 ohms to 1,000,000 ohms. The
higher the resistance of any resistor, the smaller the current which will flow through it.
Figure 1: Resistor
2.2. Capacitors
A capacitor is a device that stores energy in the form of electricity. The simplest form of
capacitor takes the form of two flat metal sheets separated by air; connections are made to
each plate, as Figure 1 shows. If you imagine a pair of these plates, 30 cm square and
separated from each other in air by 1 mm, the capacitance of this device would be almost
exactly 80 Pico farads (pF), i.e. 80 million-millionths of the unit of capacitance, the farad.
Now this is quite a small value, you will agree, and it comes about because the farad is such a
large unit. Nevertheless, as you will probably know, we may have capacitors of value 10 000
5
microfarads (F) in our radio equipment, and they can be smaller than your little finger, so
they are obviously not made the same way! (Scherz, 2000)
But two sheets, or strips, of foil can be placed one on top of the other, separated by a thin, no
conducting sheet such as paper, and then the whole assembly can be rolled up to get a large
effective surface area. When this is done, the electric flux becomes great enough so that the
device exhibits significant capacitance. In fact, two sets of several plates each can be meshed
together, with air in between them, and the resulting capacitance will be significant at high ac
frequencies.
In a capacitor, the electric flux concentration is multiplied when a dielectric of a certain type
is placed between the plates. Plastics work very well for this purpose. This increases the
effective surface area of the plates, so that a physically small component can be made to have
a large capacitance. The voltage that a capacitor can handle depends on the thickness of the
metal sheets or strips, on the spacing between them, and on the type of dielectric used
(Gibilsco, 2002).
There are many types of capacitors depending on materials used or dielectric material. These
are ceramic, electrolytic, paper, plastic -film, semiconductor, tantalum, and mica capacitors.
Figure 2: Capacitor
Applications of capacitors range from energy storage as temporary battery, power
conditioning by removing DC noise, pulsed power, power factor correction, sensors, tuning
and many more. They are versatile electronic components because of their extended
applications.
2.3. Triac
TRIAC is an acronym that has been coined to identify the triode AC semiconductor switch
which is triggered into conduction by agate signal in a manner similar to the action of a SCR.
The triac, generally called a bidirectional triode thyristor, first developed by general electric,
differs from the SCR in that it can conduct in both directions of current flow in response to a
positive or negative gate signal.
6
The primary objective underlying development of the triac was to provide a means for
producing improved controls for AC power. The use of SCR has proven the technical
feasibility and benefits of the basic functions of solid state switching and phase control. The
triac is able to conduct in a number of ways - more than the thyristor. It can conduct current
irrespective of the voltage polarity of terminals MT1 and MT2. It can also be triggered by
either positive or negative gate currents, irrespective of the polarity of the MT2 current. This
means that there are four triggering modes or quadrants:
Triac applications
Triacs are used in many applications. These electronic components are often used in low to
medium power AC switching requirements. Where large levels of power need to be switched,
two thyristors / SCRs tend to be used as they can be controlled more easily.
Nevertheless, triacs are widely used in many applications:
Lighting control - especially domestic dimmers.
Control of fans and small motors.
Electronic switches for general AC switching and control.
There are naturally many other triac applications, but these are some of the most common.
(poole, n.d.)
Figure 3: Triac
7
2.4. Cables and Connectors
Wires and cables provide low-resistance pathways for electric currents. Most electrical wires
are made from copper or silver and typically are protected by an insulating coating of plastic,
rubber, or lacquer. Cables consist of a number of individually insulated wires bound together
to form a multiconductor transmission line. Connectors, such as plugs, jacks, and adapters,
are used as mating fasteners to join wires and cable with other electrical devices (Scherz,
2000).
These are male male jumper wires.
Figure 4: Wires/connectors
2.5. Diodes
A diode is a two-lead semiconductor device that acts as a one-way gate to electric current
flow. When a diode‘s anode lead is made more positive in voltage than its cathode lead—a
condition referred to as forward biasing—current is permitted to flow through the device.
However, if the polarities are reversed (the anode is made more negative in voltage than the
cathode)—a condition referred to as reversed biasing—the diode acts to block current flow.
Diodes are used most commonly in circuits that convert ac voltages and current into dc
voltages and currents (e.g., ac/dc power supply). Diodes are also used in voltage-multiplier
circuits, voltage-shifting circuits, voltage-limiting circuits, and voltage-regulator circuits.
A pn-junction diode (rectifier diode) is formed by sandwiching together n-type and p-type
silicon. In practice, manufacturers grow an n-type silicon crystal and then abruptly change it
to a p-type crystal. Then either a glass or plastic coating is placed around the joined crystals.
The n side is the cathode end, and the p side is the anode end (Scherz, 2000).
Some dopants will create a type N structure in which there are some extra electrons simply
hanging out with nowhere to go. Other dopants will create a type P structure in which there
are missing electrons, also called holes. So, we have one type N that will conduct negative
charges with a little effort. We have another type that not only does not conduct but actually
has holes that need filling. A cool thing happens when we smash these two types together.
8
Due to the interaction of the holes and the free electrons, a diode allows current to flow in
only one direction. A perfect diode would conduct electricity in one direction without any
effect on the signal. In actuality, a diode has two important characteristics to consider: the
forward voltage drop and the reverse breakdown voltage (Ashby, 2012)
Here are some uses of diodes: Rectification, detection, Frequency multiplication, mixing,
Switching, Voltage regulation, Amplitude limiting, Frequency control, oscillation and
amplification, and energy emission.
Figure 5: Diodes
9
Figure 6: Printed circuit board
10
mode. The default baud rate of HC-05 in command mode is 38400bps and 9600 in data
mode.
HC-05 module has two modes,
1. Data mode: Exchange of data between devices.
2. Command mode: It uses AT commands which are used to change setting of HC-05.
To send these commands to module serial port is used.
2. VCC: Connect 5 V or 3.3 V to this Pin.
3. GND: Ground Pin of module.
4. TXD: Transmit Serial data (wirelessly received data by Bluetooth module transmitted out
serially on TXD pin)
5. RXD: Receive data serially (received data will be transmitted wirelessly by Bluetooth
module).
6. State: It tells whether module is connected or not.
HC-05 module Information
HC-05 has red LED which indicates connection status, whether the Bluetooth is connected or
not. Before connecting to HC-05 module this red LED blinks continuously in a periodic
manner. When it gets connected to any other Bluetooth device, its blinking slows down to
two seconds.
This module works on 3.3V. We can connect 5V supply voltage as well since the module has
on board 5 to 3.3 V regulator.
As HC-05 Bluetooth module has 3.3V level for RX/TX and microcontroller can detect 3.3 V
level, so, no need to shift transmit level of HC-05 module. But we need to shift the transmit
voltage level from microcontroller to RX of HC-05 module.
The data transfer rate of HC-05 module can vary up to 1Mbps is in the range of 10 meters.
Bluetooth communication between Devices
E.g. Send data from Smartphone terminal to HC-05 Bluetooth module and see this data on
PC serial terminal and vice versa.
To communicate smartphone with HC-05 Bluetooth module, smartphone requires Bluetooth
terminal application for transmitting and receiving data. Bluetooth terminal applications can
be found for android and windows in respective app. store.
So, when we want to communicate through smartphone with HC-05 Bluetooth module,
connect this HC-05 module to the PC via serial to USB converter.
Before establishing communication between two Bluetooth devices, 1st we need to pair HC-
05 module to smartphone for communication.
11
Pair HC-05 and smartphone:
search for new Bluetooth device from phone. You will find Bluetooth device with ―HC-05‖
name.
Click on connect/pair device option; default pin for HC-05 is 1234 or 0000. (Anon., 2023)
2.8. Arduino
Arduino, an open-source electronics platform, has become the go-to option for anyone
working on interactive hardware and software projects. An Arduino board (such as the Uno)
connected to a breadboard with plugins such as inputs, sensors, lights, and displays can be
controlled by a code written in the Arduino development environment. How to achieve this is
by prototyping with Arduino. Prototyping with Arduino has grown in popularity with the
increased use of the Arduino platform (Kondaveeti, 2021).
There are many versions of this board; Arduino Uno is the simplest one to use and the best
one for learning on. The Arduino has a row of strips at the top and the bottom with lots of
labels. These strips are the connectors, which are used to attach to sensors and actuators.
Those connectors here is an explanation of the input and output pins. In fact, there are a
variety of Arduino boards, but the most common one by far is the Arduino Uno.
It has 14 Digital I/O pins (pins 0–13). These pins can be either inputs or outputs. Inputs are
used to read information from sensors, while outputs are used to control actuators. The
12
programmer needs to specify the direction (in or out) in the sketch he creates in the IDE.
Digital inputs can only read one of two values, and digital outputs can only output one of two
values (HIGH and LOW). it has 6 Analogue In pins (pins 0–5) The analogue input pins are
used for reading voltage measurements from analogue sensors. In contrast to digital inputs,
which can distinguish between only two different levels (HIGH and LOW), analogue inputs
can measure 1,024 different levels of voltage.
It has 6 Analogue Out pins (pins 3, 5, 6, 9, 10, and 11), These are actually six of the digital
pins that can perform a third function: they can provide analogue output. As with the digital
I/O pins, you specify what the pin should do in your sketch. The board can be powered from
your computer‘s USB port, most USB chargers, or an AC adapter (9 volts recommended, 2.1
mm barrel tip, and center positive). Whenever power is provided at the power socket,
Arduino will use that, and if there is no power at the power socket, Arduino will use power
from the USB socket. It‘s safe to have power at both the power socket and the USB socket.
(Banzi, 2015)
Figure 8: arduinouno
13
ICs come in analog, digital, or analog/digital form. Analog (or linear) ICs produce, amplify,
or respond to varying voltages. Digital (or logic) ICs respond to or produce signals having
only high and low voltage states, whereas analog/digital ICs share properties common with
both analog and digital ICs. Some common analog ICs include voltage regulators, operational
amplifiers, comparators, timers, and oscillators. Common digital ICs include logic gates (e.g.,
AND, OR, NOR, etc.), flip-flops, memories, processors, binary counters, shift registers,
multiplexers, encoders and decoders, etc. Analog/digital ICs may take on a number of
different forms (Scherz, 2000). Optocouplers ICs use optoelectronic coupling, are often used
to convey information from the secondary output circuits back to the input primary control
circuits without compromising the galvanic isolation between the two.
However, optocouplers have a number of parameter variations and limitations, which must be
considered at the design stage if problems are to be avoided. Of particular interest are
variations in transfer ratio with device type and operating temperature, stability problems
caused by the nonlinear current transfer ratio, and the considerable variations among devices
of the same family. Further, a particular optocoupler may change its parameters considerably
throughout its working life (aging). Finally, the inter electrode capacitance, although small,
can cause noise problems because of the high gain in the optotransistor. As a result of these
limitations, the optical coupler should not be used in an open-loop mode, where such changes
would have a direct effect on the performance (Billings, 2011).
2.10. Lamp
Lamps are devices that convert electric current into light energy. One approach used in the
conversion process is to pass a current through a special kind of wire filament. As current
collides with the filament‘s atoms, the filament heats up, and photons are emitted (As it turns
out, this process produces a variety of different wavelength photons, so it appears that the
emitted light is white in color). Another approach used to produce light involves placing a
pair of electrodes a small distance apart within a glass gas-enclosed bulb. When a voltage is
14
set across the electrodes, the gas ionizes (electrons are striped from the gas atoms) emitting
photons in the process (Scherz, 2000).
15
CHAPTER THREE: METHODOLOGY
3.1. Introduction
In this section I indicate in details the various procedures that will be followed during the
project implementation process. This section includes the following parts: study area, study
design, procedures and methods, data analysis, problems and limitations, and ethical
considerations.
During implementation, some important tools will be used. Here are some:
Digital multi meter
Screwdrivers
Pliers
Soldering iron and disordering wire
16
3.2.2. Programming
Programming allows us to set instructions that the processor will perform in order to
accomplish our desired task. for this project the program will output the illumination after
processing the input from Bluetooth module. This will be done by using software Arduino
IDE for designing the codes necessary to process inputs and for automatic operations. The
program will be uploaded to Arduino board this was by USB port through the specific USB
cable.
First the Arduino IDE should be installed on computer to get started. The IDE is a special
program running on your computer that allows writing sketches for the Arduino board in a
simple language modeled after the Processing language. The magic happens when you press
the button that uploads the sketch to the board. The code written is translated into the C
language (which is generally quite hard for a beginner to use), and is passed to the compiler,
an important piece of open source software that makes the final translation into the language
understood by the microcontroller. This last step is quite important, because it‘s where
Arduino makes your life simple by hiding away most of the complexities of programming
microcontrollers. The programming cycle on Arduino is basically as follows:
1. Plug your board into a USB port on your computer.
2. Write a sketch that will bring the board to life.
3. Upload this sketch to the board through the USB connection and wait a couple of seconds
for the board to restart.
4. The board executes (performs) the sketch that you wrote.
17
3.5. Problems and Limitations of the project
In this project I will not be able to cope with some technical problems. Electromagnetic
interferences. Important tools and devices ideal to optimum operation will be replaced with
the less sophisticated ones. The setup is likely to be bulky and cumbersome. The circuit will
operate only on normal residential supply voltage. There won‘t be a means to measure the
illumination of the lamp. Main problem for these limitations is financial.
18
CHAPTER FOUR: DESIGN AND IMPLEMENTATION OF
ILLUMINATION CONTROL WITH PRECISION USING ARDUINO
WITH BLUETOOTH
4.1. Introduction
This is chapter will explain how the illumination control using Arduino with Bluetooth
system will be done. The system itself has three important parts, the first one is input part that
includes a Bluetooth module and a smartphone. The smartphone is linked to the module
through Bluetooth and android application named Serial Bluetooth Terminal. The second is a
control part that contained by microcontrollers which are used to control all system. In this
project the main control device is ATmega microcontroller Arduino Uno.it processes the
input from Bluetooth and provides the output to the triac and communicates the output to
smartphone through Bluetooth. The last part is the output that is the Triac and the lamp. Triac
is a bidirectional semiconductor controlled rectifier which can be turned on in either of the
direction by providing triggering pulse at its gate. The lamp provides the illumination
according to amount of voltage getting through the triac.
Bluetooth module
Arduino
Triac Lamp
19
4.2.2. Circuit diagram of the study
20
4.2.3. Specifications and calculation
Table 1: component specifications
NAME TYPE SUPPLY FREQUENCY OTHERS
VOLTAGE
1 Arduino uno ATMega328P 7-12V 32Kb Flash
memory , 2Kb
SRAM, 1kb
EEPROM
2 Bluetooth HC-05 1.8V 2.4GHz -80dBm
module Operation,3.3V sensitivity, up to
to 5V I/O +4dBm RF
transmit power
3 Triac BT 136 600V PGM=5W,
ITSM=25A,
IGM=2A,
IT(RMS)=4A
4 Lamp 220V
5 Optocoupler MOC3021 VDRM=400V, PD=330mW
Triac driver VR=3V,
VISO=7500Vac(
pk)
6 Zero EL817 VCEO= 35V max PD=100mW
crossing VISO= 5000Vrms
detector max
7 Resistors three
1kohm,two
100kohm,470
ohm, 10k ohm
21
4.3. Implementation of the study
4.3.1. Working principle of the study
To control the illumination, the circuit uses phase control technique and static switching
characteristics of a Triac, the Triac is used to switch the AC lamp, as this is a power
electronic fast switching device which is the best suited for these applications.
To control the AC voltage, the first thing I have to do is, to detect the zero crossing of the AC
signal Hence, every time the signal comes to Zero point, I have to detect that point and after
that trigger the Triac as per the power requirement. So, I have to detect when the voltage
passes from positive to negative or from negative to positive and synchronize our pulse with
that so it will fire always in the same spot. For that, I will use a full bridge rectifier. This will
give the output both the positive and negative curves of the AC wave.
First I have to detect the zero-cross since the pulse needs to be in phase with the AC voltage.
So, we have to detect when the voltage passes from positive to negative or from negative to
positive and synchronize our pulse with that so it will fire always in the same spot. For this
full-bridge rectifier is used which will give the output both the positive and negative curves
of the AC wave. The Triac is triggered at a firing angle of 90 degrees by applying a small
gate pulse signal to it. There is delay time which we have to give as per our dimming
requirement. For example, in this case as the firing angle is 90 percent, hence the power
output will also be halved and hence the lamp will also glow with half intensity.
Optocoupler is also known as Opto-isolator. It is used to maintain isolation between two
electrical circuits like DC and AC signals. Basically, it consists of an LED that emits infrared
light and the photo sensor which detects it. Here we are used a MOC3021 opt coupler to
control the AC lamp from microcontroller signals which is a DC signal.
All we have to do is to control the time between the zero-cross and when we fire the pulse at
the Triac gate in order to control power. l used UART Communication through Bluetooth
HC-05 to change the delay timing.
22
23
Figure 13: implementation of project
24
4.3.3. Cost estimation
Table 2: cost estimation
Name Quantity Price (RWF)
1 Arduino uno 1 15,000
2 Bluetooth module 1 7,000
3 Triac 1 1,000
4 MOC3021 1 1,000
Optocoupler
5 EL817 Optocoupler 1 1,000
6 PCB 1 2,000
7 Resistors 7 700
8 Diodes 4 400
9 Soldering iron 1 4000
10 Connector wires 20 1,000
11 Lamp 1 1,000
TOTAL 34,100
25
CHAP 5: SUMMARY, CONCLUSION AND RECOMMENDATIONS
5.0 Summary
The main objective of this project was to build an illumination control system using Arduino
with Bluetooth. First I designed the circuit for the system and then implemented the system.
The designed circuit was minimal in terms of components. The prototype was successfully
built on a through whole PCB and then soldered. Finally, I tested the prototype by my
smartphone as input to Bluetooth that in turn provides input to the Arduino to determine the
amount of illumination needed.
After testing, I would say the prototype run successfully as I was able to control the
illumination of an incandescent lamp according to inputs zero to nine that determines the
percentage of voltage getting through and hence the amount of illumination. The type of lamp
and its state determines the illumination that we get. Electronic lamps did not work for this
system.
5.1 Conclusion
The illumination control using Arduino with Bluetooth is done to precision in this project.
Users of this control can get desired control of the illumination conveniently, and quickly.
Illumination control is not given much importance in our society, but it is amazing how much
change it can bring to a better world. Think about difference in individual illumination
preferences, and work related illumination. Eye diseases are many in our society, and
illumination control is one factor that can help the prevention and alleviation of such
complexities.
5.2. Recommendations
I recommend this project to multipurpose hall owners in order to cater better to their
customers also indoors farmers, and generally all lighting as they at one moment need it.
I recommend to future researchers to improve the power dissipations and portability. Even
better would be rendered more programmable than circuitry. I think integrated circuits
developed for this sole purpose can solve its complexity and downsides.
26
REFERENCES
27
APPENDIX
void zero_cross_detect() {
zero_cross = true; // set the boolean to true to tell our dimming function that a zero
cross has occured
i=0;
digitalWrite(AC_pin, LOW); // turn off TRIAC (and AC)
}
void dim_check() {
if(zero_cross == true) {
if(i>=dim) {
28
digitalWrite(AC_pin, HIGH); // turn on light
i=0; // reset time step counter
zero_cross = false; //reset zero cross detection
}
else {
i++; // increment time step counter
}
}
}
void loop() {
if(Serial.available() > 0){ // Checks whether data is comming from the serial port
state = Serial.read(); // Reads the data from the serial port
}
if (state == '0') {
Serial.println("0%"); // Send back, to the phone, the String "LED: ON"
dim=128;
}
else if (state == '1') {
Serial.println("11%");;
dim = 112;
}
else if (state == '2') {
Serial.println("22%");;
dim = 98;
}
else if (state == '3') {
Serial.println("33%");;
dim = 84;
}
else if (state == '4') {
Serial.println("44%");;
dim = 70;
29
}
else if (state == '5') {
Serial.println("55%");;
dim = 56;
}
else if (state == '6') {
Serial.println("66%");;
dim = 42;
}
else if (state == '7') {
Serial.println("77%");;
dim = 28;
}
else if (state == '8') {
Serial.println("88%");;
dim = 14;
}
else if (state == '9') {
Serial.println("100%");;
dim = 0;
}
delay(60);
}
30