wpt finalprogressreport

48
WIRELESS POWER CHARGING SYSTEM By Ubong Udoessien Tamim Alkhonaini Nadeem Qandeel Senior Design Progress Report Submitted to: Advisor: Dr. Aiping Yao _________________________ Signature Committee: Dr. Glazos _________________________ Signature Dr. Petzold _________________________ Signature Department of Electrical and Computer Engineering College of Science and Engineering 1

Upload: nadeem-qandeel

Post on 13-Apr-2017

268 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: WPT FinalProgressReport

WIRELESS POWER CHARGING SYSTEMBy

Ubong UdoessienTamim AlkhonainiNadeem Qandeel

Senior Design Progress Report

Submitted to:Advisor:

Dr. Aiping Yao

_________________________ Signature

Committee:

Dr. Glazos

_________________________ Signature

Dr. Petzold

_________________________ Signature

Department of Electrical and Computer EngineeringCollege of Science and Engineering

1

Page 2: WPT FinalProgressReport

Abstract

Wireless power transfer is the transmission of electrical power from a source to an electrical load without the need of conducting wires or materials. The project can be done through magnetic coupling between copper coils. The technology of wireless power transfer is getting a particular interest from the industry due to it is numerous applications.

2

Page 3: WPT FinalProgressReport

Table of Contents:

1. Introduction· Background · Problem Statement· Design Objectives · Design Specifications · Constraints

2. Design Methodology · Design Alternative· Research Concepts· System Level Design· Future Work

3. Testing · Accomplishments· Testing and Results

4. Budget

5. Schedule

6. Conclusion· Summary· Lessons Learned

7. References8. Appendices

3

Page 4: WPT FinalProgressReport

List of Figures

Figure 1 Transmitter Coils.............................................................................................................................7Figure 2 Receiver Coils.................................................................................................................................8Figure 3 ATmega328.....................................................................................................................................9Figure 4 FSR 406.........................................................................................................................................10Figure 5 A1 design schematic......................................................................................................................11Figure 6 Coil Arrangement for Wireless Inductive Power Transmission System.......................................12Figure 7 Resonant Coupled Windings with Resonant Capacitors...............................................................13Figure 8 Impedance Matching of a coupled circuit.....................................................................................14Figure 9 Qi Logo..........................................................................................................................................14Figure 10 Block diagram of system configuration......................................................................................15Figure 11 Sensor simulation circuit.............................................................................................................17Figure 12 Standalone ATMEGA328...........................................................................................................18Figure 13 PWM signal before filtering........................................................................................................20Figure 14 Two PWM signals filtered and going to transmitter...................................................................21Figure 15 serial communication monitor from microcontroller to PC........................................................22Figure 16 LCD screen..................................................................................................................................23Figure 17 LED indicators.............................................................................................................................24Figure 18 PWM signals with 80 KHz and 13V Pk-Pk................................................................................25Figure 19 LT Spice simulation of receiver circuit.......................................................................................26Figure 20 DC results....................................................................................................................................26Figure 21 Project expenses..........................................................................................................................29Figure 22 Work Schedule............................................................................................................................30Figure 23 Gantt chart...................................................................................................................................31

4

Page 5: WPT FinalProgressReport

1. Introduction

1.1 Background

Wireless power transfer is the transmission of electrical power from a source to an

electrical load without the need of conducting wires or materials. The possible applications of

wireless power systems extend from wireless charging of phones and other consumer devices to

higher power applications like electric vehicles.

Wireless power transfer is getting particular interest from the mobile phone and the

electric vehicle industry. The industry realizes the demand for wireless power charging where

mobile devices can be charged without the need for connecting wires.

Wireless energy transfer has been around for some time since the inventions of Nicola

Tesla in the late 1800’s. Now there is widespread interest in finding suitable applications in

consumer products. The most common and probably the oldest consumer application of wireless

energy transfer can be found in the electric toothbrush.

Essential to the endorsement of wireless power transfer by consumers and industry as a

means of powering devices is the efficiency of the power transfer when compare to a convention

plug and socket power supply.

1.2 Problem Statement

The aim of the project is to produce a demonstration of wireless power system for

charging a mobile phone and illustrate how magnetic coupling can be used to transfer energy

wirelessly.

1.3 Design Objectives

The overall purpose of the project is to demonstrate how a wireless power system works

for charging a mobile phone or multiple phones. To illustrate how magnetic coupling work and

how resonant magnetic coupling could improve the level of power transferred at a distance.

5

Page 6: WPT FinalProgressReport

Most of the project research will consist of; conducting experiments in different circuit

designs to achieve a wireless power system and improve on the performance, the addition of the

microcontroller element to be able to control specific tasks that are unique to this project. The

factors and implementations that allow for wireless charging of a mobile phone lithium battery

will be researched. It is of most importance that the research and any following lab

demonstration comply with the Qi standard.

The Qi standard will be the foundation on which any final demonstration or prototype

will be developed. The Qi standard identifies the coil design, coil size, shielding and positioning.

The wireless charging project should explore the two different wireless charging outlines in the

Qi standard, guided positioning and free positioning.

1.4 Design Specifications

The key components that will bring about the success of this project include; the

transmitter circuit, the receiver circuit, the copper coils, and the micro-controller. To each of

these components a set of specifications that allows them to be beneficial to the need of the

project.

The transmitter coil has to have certain dimension and so does the receiver coil, to ensure

that mutual magnetic induction occurs between the two coils. Just as mutual inductance is

witnessed in a transformer it operates in this project under the same principle, as the current

flowing in the transmitter coil induces a voltage in the adjacent receiver coil, which in turn

causes current flow in the second coil.

Figure 1 Transmitter Coils.

6

Page 7: WPT FinalProgressReport

Table 1 Transmitter Coil Parameters.

Parameter Symbol Value

Outer diameter do 43+-0.5mm

Inner diameter di 20.5+-0.5mm

Thickness dc 2.1+-0.5mm

Number of Turns per Layer N 10

Number of Layers – 2

The receiver coil is a key component in a successful and efficient design of a Qi-

compliant receiver things to be considered in the design is the shield, wire gauge and number of

turns.

Figure 2 Receiver Coils.

7

Page 8: WPT FinalProgressReport

Table 2 Receiver Coil Parameters

The ATmega328 chip of the Arduino Uno has 14 digital input/output pins (of which 6

can be used as PWM outputs), 6 analog inputs, on the breadboard connected to the chip will be a

16MHz ceramic resonator, a USB connection, a power jack, an ICSP header, and a reset button

to allow the use of the microcontroller with full functionality.

Figure 3 ATmega328.

8

Page 9: WPT FinalProgressReport

Table 3 Arduino Uno Specifications.

Parameter Value

Input Voltage 7V - 12V

Operating Voltage 5V

Digital Pins 14 (6PWM)

Analog Pins 6

Flash Memory/EEPROM 32KB/1KB

The FSR used is a force sensing resistors, or FSRs, are robust polymer thick film (PTF)

devices that exhibit a decrease in resistance with increase in force applied to the surface of the

sensor. It allows the user to detect physical pressure, squeezing and weight. They are simple to

use and low cost.

Figure 4 FSR 406.

9

Page 10: WPT FinalProgressReport

1.5 Constraints

Few constraints have risen since the proposal of the project, those constraints have been

in the areas of future communication work and wireless charging including both the transmitter

and the receiver.

The ultimate goal for the transmitter unit is to achieve a high voltage and about 700mA at

its end, but the first couple of transmitter circuits designed have failed to produce the wanted

outcome, one circuit schematic was the A1 design shown below.

Figure 5 A1 design schematic.

One of the challenges in this circuit is that it required four high frequency PWM signals

that the microcontroller had troubles providing, in addition to the occurrence of cross conduction

which was a result of the PWM signal being on at the same time rather than one is off while the

other is on, along with other many problems this was the reason for the circuit’s failure to

provide the expected outcome and rather it was supplying 2.4V with 0.1mA which is not enough

to transfer to the receiver and charge the phone. A solution to the problem mentioned above was

to switch to the half bridge circuit that requires only 1 PWM signal and its toggle signal.

Another constraint we had was in the initial proposal to use the Bluetooth capability in

the phone for communication medium, but the Bluetooth requires prior pairing between each

phone, in addition to the fact that communication can’t be established when the phone is off

because Bluetooth will be off as well. A solution to this problem was to switch to NFC

technology which requires no pairing between the tag and the reader in TX and Rx unit.

10

Page 11: WPT FinalProgressReport

Also the tag in the receiver unit doesn’t require power to turn on which makes it perfect for the

dead phone situation.

2. Design Methodology

2.1 Design Alternative

Wireless power transfer by inductive coupling consist of a transmitter coil and receiver

coil whereby both systems forms a system of magnetically coupled inductors. An alternating

current on the transmitter coil generates a magnetic field which induces a voltage in the receiver

coil. The induced voltage, conditioned through the receiver circuit can be used to power a device.

The efficiency in power transfer is dependent on the coupling factor (k) between both

primary coil (L1) and secondary coil (L2) and their quality factor (Q). K, the coupling is a

function of the distance between the inductors (z) and its ratio (D2/D). The coupling factor is

determined as follows:

Where, M is the mutual inductance of the primary coil (Lp) and secondary coil (Ls).

11

Figure 6 Coil Arrangement for Wireless Inductive Power Transmission System

Page 12: WPT FinalProgressReport

The quality factor (Q) which is the ratio between the inductance of a coil, its resonant frequency

(w) and its resistance (R) is expressed as follows:

Resonant Inductive Coupling.

Resonant circuits are used to enhance the inductive power transmission for systems with

low coupling factor. To ensure effective coupling between both transmitter and receiver side, it is

important that both sides resonate at the same frequency. An LC circuit which is also called a

tuned circuit consist of inductance of the coil (L) and a resonant capacitor (C). This circuit stores

energy oscillating as the circuit’s resonant frequency (fr). This relationship is determined as

follows:

12

Figure 7 Resonant Coupled Windings with Resonant Capacitors

Page 13: WPT FinalProgressReport

Reflected Impedance.

Impedance matching is a good way to optimize inductive coupling by ensuring that the resonant

tank capacitance is implemented at the secondary side by adding a capacitor either in parallel or

in series. Fig 6 shows a typical circuit with matching impedance configuration.

Figure 8 Impedance Matching of a coupled circuit.

2.2 Research Concepts

Section 2.1 details the research concept employed for this project.

For this project, inductive coupling will be used to implement a wireless power transfer.

The initial goal for this project involved transmitting power over a distance of 2m. However,

after careful consideration of safety concerns, it was determined to build a system with a shorter

range that can still power a mobile device. The design chosen followed the Qi standard which

allowed for power transfer of 5W.

2.3 System Level Design.

This project was implemented using the Qi standard which is a product of the Wireless Power

Consortium whose main goal of was set a standard for wirelessly powering mobile devices. The

13

Page 14: WPT FinalProgressReport

Qi standard has been adopted by major phone companies as the preferred wireless transfer

standard. Hence, in implementing this project, the Qi standard design employed is the A1 Power

Transmitter design A1. The Qi standard allows the developer design freedom in implementing

the transmitter and receiver circuit.

The system consists of three main parts:

1. Transmitter unit.

2. Receiver unit.

3. Control and Communication Unit.

Below block diagram illustrates the system configuration of the wireless power transfer

implemented.

Transmitter Circuit.

14

Page 15: WPT FinalProgressReport

The transmitter unit henceforth called the base-station consist half-bridge inverter and

primary coil. The inverter converts the step down DC input to an AC waveform that drives a

resonant circuit which consist of the primary coil plus a series capacitor. The primary coil will

have a resolution of 5mA. Operating frequency range of the inverter will be between 110 - 205

KHz.

Receiver Circuit

The Receiver unit consist of a dual resonant circuit, rectifier circuit, a communication

modulator and dc filter. The dual resonant circuit consist of secondary coil (Rx coil), series and

parallel capacitances to enhance the power transfer efficiently. The rectification circuit will

provide a full wave rectification of the AC from the Rx Coil using a full bridge configuration to

provide smoothing while the communications modulator will control the primary coils current

and voltage. A voltage regulator (LM7805C) will be used to regulate the receiver’s output to 5

Volts.

Control/Communication Unit.

The communications and control unit comprises the digital logic part that receives and

decodes messages from the power receiver, executes the relevant power control algorithms and

protocols, drives the frequency of the AC waveform to control the power transfer in the Tx unit

and communications modulator on the Rx unit.

The way the communication/control unit interacts with the overall system starts with the

FSR sensor that detects the presence of a phone device on its surface, this is done by employing

a voltage divider using the sensor and a 10K ohm resistor. As the phone is placed on the sensor,

the equivalent resistance decrease from infinity to a smaller value that allows current to flow in

the 10K ohm resistor causing a voltage drop that is picked up by the microcontroller and used as

a threshold to identify the presence of a cell phone device.

15

Page 16: WPT FinalProgressReport

Figure 11 Sensor simulation circuit

After the placement of a phone the microcontroller generates a PWM signal that is used

to switch the MOSFET’s in the TX unit to initiate the charging cycle and depending on what

sensor on the pad out of the four sensor is being used an LED lights.

We have simulated the rest of the three sensors using appropriate resistance value until

we purchase the rest of the sensors. The microcontroller Arduino UNO which controls the

system has been used as a standalone chip with few electronic components such as a voltage

regulator, 16MHz crystal and small capacitors and a reset button for the system.

16

Page 17: WPT FinalProgressReport

Figure 12 Standalone ATMEGA328

The LCD’s role in the control part is to simulate it is behavior in the final stage of the

project which is to portray information relevant to the phone ID and charging state, so at this

stage after the phone charged you click on one of the buttons to show one of the phones

information.

2.4 Future Work

The long term goal will be to expand the charging station to charge multiple phones by

replicating the original circuit of the transmitter circuit and adding more coils, so it can charge

four phones at the same time, taking into consideration the necessary power requirements to

integrate a bigger transmitter station. Moreover, we will include a communication unit that will

allow the transfer of data from the receiver unit attached to the phone to the microcontroller in

the transmitter unit, so that the output of the transmitter circuit is monitored and regulated upon

need in addition to processing the data and displaying it on a LCD screen to notify the user of

phone’s charging status.

17

Page 18: WPT FinalProgressReport

In more details we would like to increase the output of the transmitter current to 1A so

that we can also charge bigger electronic devices such as IPad etc. Also adding a protective

feature that will stop the transmitter from continuing to charge the phone when the phone reaches

a full charging percentage.

To achieve these goals we will be relying on heavy research in the areas of

communication and small power distribution systems. In addition to simulations to optimize the

performance of the transmitter circuit by improving the resonant coupling circuit, reducing losses

in the circuit and any form of overheating.

3. Testing

3.1 Accomplishments

1) Transfer 5W power between the transmitter and the receiver units using inductive

coupling.

2) Charge one phone wirelessly using inductive coupling.

3) Used resonant coupling technique using the receiver, function generator and coils to light

an LED.

4) Initialize and program ATMEGA328 chip standalone to control the system and generate

a range of high frequency PWM signal with controlled duty cycles

5) Program an LCD to display output and control output using buttons.

6) Implement the use of a sensor in the system to detect phones on the base station.

3.2 Testing and Results

Testing has a great importance in this project, all significant progress occurred when

simulation and calculations agreed, to give a successful practical testing in the lab.

18

Page 19: WPT FinalProgressReport

A. Controls and Communication

1. PWM Generation:

One of the key components to this project is the generation of the PWM signal. PWM

signal controls the switching frequency of the half bridge inverter circuit. Two PWM signal will

be generated from the Arduino microcontroller each signal will be sent to each of the MOSFET’s

in the half bridge circuit in the transmitter.

In the lab using an oscilloscope the PWM signal generated can be measured and

displayed on a channel as can be seen in figure below.

Figure 13 PWM signal before filtering

19

Page 20: WPT FinalProgressReport

In this figure, 3 PWM signals are generated and one of them is phase shifted as it shows

for testing purposes. Now the Arduino can generate up to 6 PWM signals from 6 pins, each pin

has a predefined frequency that is set by the chip designers.

To be able to change the frequency of the PWM signal generated from the chip like we

need to do in this project, we have to play with timers of the Arduino, since we also need to

generate high frequency signals that ranges from 100KHz to 200KHz, to achieve that, a new

code has to be written that changes that changes the registers and only then the Arduino can

generate up to 4 PWM’s instead of 6. The reason is each 2 PWM’s are linked to a timer and one

of the timers controls the clock of the chip hence control the delays functions so that timer

should remain unchanged.

In the figure below we can see a clean filtered version of 2 PWM signals with 200 KHz

frequency, 50% duty cycle and 0.9% noise.

Figure 14 Two PWM signals filtered and going to transmitter

2. Weight Sensor

20

Page 21: WPT FinalProgressReport

The FSR is a device that allows the detection of a physical object that is placed on it. It

has a 4cm x 4cm active area for detection and can detect from 10g to 1kg of weight.

The way this works is that as the resistance of the FSR decreases, the total resistance of

the FSR and the pull down resistor decreases from about 100Kohm to 10Kohm. That means that

the current flowing through both resistors increases which in turn causes the voltage across the

fixed 10K resistor to increase.

Best way to test it is to connect it across an ohmmeter and apply weight and notice how

the reading changes on the meter. For further testing using the Arduino a sketch was to made to

take the analog voltage reading and use that to determine how bright the red LED is. The harder

you press on the FSR, the brighter the LED will be! Connecting the LED to a PWM pin.

In the figure below another sketch was made to measure the voltage across the resistor,

analog reading of the Arduino, FSR resistance and measure the approximate Newton force

measured by the FSR.

21

Page 22: WPT FinalProgressReport

Figure 15 serial communication monitor from microcontroller to PC.

Eventually the sensor was connected to the circuit and Arduino successfully and triggered

the generation of the PWM signal when a phone is placed on it.

3. LCD

22

Page 23: WPT FinalProgressReport

The LCD used is an Omnix 16x2 LCD. It will be used to display phone information and

battery charge percentage. First step was to test the LCD output by displaying characters on it

using the Arduino to program it, then to test the backlight of the LCD and make it brighter using

a potentiometer and last step was to test the buttons connected to the LCD to bring new

information to the screen.

Figure 16 LCD screen.

In a similar photo to the one above, the LCD display shows the following the message;

“Press a button to show phone” as the user clicks a button out of the four button, information of

the corresponding phone would show stating the phone-number and the battery charging

percentage. In the program running the LCD, the change in battery charge percentage is

simulated by sending a different number every 3 seconds to update the phone charge.

4. LED Indicators

23

Page 24: WPT FinalProgressReport

Since the base station can host four phones simultaneously, there are four phone light

indicators each indicator corresponds to one of the four charging pads, as each phone charges an

LED indicator needs to light to show that for example phone 1 is being charged. Once the phone

has been removed from the base station the LED turns off. This process is achieved with the help

of the sensor and microcontroller as the sensor tells the MC that a phone is place, which in return

turns the LED on.

Figure 17 LED indicators

As shown in the picture the light green on the most left represents that phone 4 is

charging and the second green light to the right shows that phone 2 is charging. The two red

lights in the center represent the 2 PWM signals the microcontroller is generating.

B. Transmitter Unit

The transmitter circuit design implements a half-bridge inverter to drive the primary coil

and the series resonant capacitor. Design specification A1 identifies an input voltage of 19±1 V

to the half bridge inverter. The operating frequency of the half bridge inverter, fop is chosen

between 110 kHz and 175 kHz with a duty cycle of 50%. For testing purposes, 77 KHz operating

frequency was used for testing purposes. The 5V Pulse Width Modulator (PWM) signal was

provided by an Arduino Uno.

24

Page 25: WPT FinalProgressReport

An half-bridge driver IC (IRS2103I was used to amplify the 5V PWM to at least 10V to drive the

n-channel MOSFET (FQA55N25) which requires a 10V gate voltage with a 5V gate threshold

value to turn on. The voltage supply for both the driver and n-channel MOSFET was

C. Receiver Unit

1. Using function generator as an input:

Table 4 Function generator parameters

Wave Frequency (kHz) Vpp (V) Current (A)

Sine 125 10 0.1

The receiver unit was tested using a function generator as an input with the parameters

indicated above. Since the function generator cannot provide enough current, the output power of

25

Figure 18 PWM signals with 80 KHz and 13V Pk-Pk.

Page 26: WPT FinalProgressReport

the receiver unit is not high enough to charge a phone. The output current is 0.03 mA and the

output voltage is 4.9 V.

Figure 19 LT Spice simulation of receiver circuit.

Figure 20 DC result

2. Using inductive coupling:

The receiver unit was tested using inductive coupling between the transmitter and

receiver units. At this point, the transmitter unit can provide enough current to charge a phone.

The output current is 0.45 A and the output voltage is 4.8 V.

3. Testing a phone

26

Page 27: WPT FinalProgressReport

An iPhone 4s was tested by connecting it to the receiver unit, where the power was

transferred to the receiver unit using inductive coupling. The phone was connected to the

receiver unit for approximately 30 minutes to test the charging percentage.

Table 5 Battery percentage

Time (Hr) Battery Percentage (%)

04:25 PM 45

04:30 PM 48

04:45 PM 59

04:55 PM 65

4. Budget

The cost for our project is pretty reasonable, we have spent more money than we should

in the first semester due to experimenting on different parts to see which gives best result and not

exactly knowing what best meets our needs. For the second semester, our budget will be much

smaller since we already know what we want and we have bought most of the needed parts this

semester.

27

Page 28: WPT FinalProgressReport

Figure 21 Project expenses

28

Page 29: WPT FinalProgressReport

5. Schedule

We are mostly on schedule for our project but a little behind in the testing part to

increase our charging system’s performance, by the end of the first semester we would have

achieved big part of the controls and have demonstrated the operation of wireless power transfer

to charge one phone.

As for next semester we will investigate how to charge more than one phone and add the

communication capability to our project to allow a more interactive charging system take place.

29

Page 30: WPT FinalProgressReport

Figure 22 Work Schedule

30

Page 31: WPT FinalProgressReport

Figure 23 Gantt chart.

6. Conclusion

6.1 Summary

Some project progress has been made to this day. As is it can be seen from the work

mentioned above, simulation and lab experimentation. We have been able to achieve all our

goals for this semester including having a comprehensive prototype system to what our product

would behave and look like. The lab work demonstrates system integration of controls,

programming and wireless power transfer in its more basic form and it is hoped that through

good research, simulations and experimentation to take the project from there and enhance the

circuitry to charge a mobile phone wirelessly.

31

Page 32: WPT FinalProgressReport

6.2 Lessons Learned

1) Weekly meeting and constant communication with our project advisor were

essential to the completion of this task.

2) We gained a lot of experience from working on our project and found the progress

presentation as an essential exercise for working in the real world.

3) Research and reading the Qi standard has been a valuable insight on how to starts

tackling the project.

4) Team work was a great experience and a helpful way to achieve this project.

5) Most important lesson learned of all was the time spent in the lab, the opportunity

to use and improve our engineering problem solving skills has been a key to

solving the problems encountered.

32

Page 33: WPT FinalProgressReport

7. References

1) The Qi interface specification. “System Description Wireless Power Transfer Volume

I: Low Power Part1: Interface Definition”. Internet:

http://www.wirelesspowerconsortium.com/blog/11/qi-specification-available-for-download

[June. 1,2013]

2) Power By Proxi. “Wireless Charging”. Internet: http://powerbyproxi.com/wireless-

charging/

3) Instructables. “Inductive Power Transfer”. Internet: http://www.instructables.com

[July 5, 2008]

4) Brad Molen. “Engadget Primed:How wireless and inductive charging works”.

Internet: http://www.engadget.com/2011/06/24/engadget-primed-how-wireless-and-

inductive-charging-works/ [June 24, 2011]

33

Page 34: WPT FinalProgressReport

8. Appendices

Code used to run the system

#include <PWM.h>#include <LiquidCrystal.h>#include <LCD16x2.h> #include <Wire.h>

LCD16x2 lcd;const int analog_pin = A0;const int analog_pin1 = A1;const int analog_pin2 = A2;const int analog_pin3 = A3;

int buttons;int buttons1;int buttons2;int buttons3;int buttons4;

//use pin 11 on the Mega instead, otherwise there is a frequency cap at 31 Hzint fsrAnalogPin = 0; // FSR is connected to analog 0int fsrAnalogPin1 = 1;int fsrAnalogPin2 = 2;int fsrAnalogPin3 = 3;

int fsrReading;      // the analog reading from the FSR resistor dividerint fsrReading1;int fsrReading2;int fsrReading3;

long randNumber;String x;char y[50];

//int LEDbrightness;//int led11 = 11;              //added//int led3 = 3;              //addedint led9 = 9;                // the pin that the LED is attached toint led10 = 10;              //added//pin13, 12, 7, 4 is used

int brightness = 0;         // how bright the LED isint fadeAmount = 5;         // how many points to fade the LED by

int32_t frequency = 77000; //frequency (in Hz)

34

Page 35: WPT FinalProgressReport

void setup(){ //initialize all timers except for 0, to save time keeping functions InitTimersSafe();

 //sets the frequency for the specified pin //bool success9 = SetPinFrequencySafe(led9, frequency); bool success10 = SetPinFrequencySafe(led10, frequency); //added //bool success11 = SetPinFrequencySafe(led11, frequency); //added// bool success3 = SetPinFrequencySafe(led3, frequency); //added //if the pin frequency was set successfully, turn pin 13 on  /*if(success9 && success10 && success3) {   pinMode(13, OUTPUT);   digitalWrite(13, HIGH); }*/         Wire.begin(); pinMode(analog_pin, INPUT); //pin A0 defined as input for LCD (pin 0 =fsr reading)  pinMode(analog_pin1, INPUT); pinMode(analog_pin2, INPUT); pinMode(analog_pin3, INPUT); lcd.lcdClear();  pinMode(fsrAnalogPin, INPUT); pinMode(fsrAnalogPin1, INPUT); pinMode(fsrAnalogPin2, INPUT); pinMode(fsrAnalogPin3, INPUT);   Serial.begin(9600);   // We'll send debugging information via the Serial monitor //pinMode(led9, OUTPUT); //pinMode(led10, OUTPUT);  randomSeed(1); }

void loop(){  fsrReading = analogRead(fsrAnalogPin); fsrReading1 = analogRead(fsrAnalogPin1); fsrReading2 = analogRead(fsrAnalogPin2); fsrReading3 = analogRead(fsrAnalogPin3);  if(fsrReading) {   pinMode(4, OUTPUT);   digitalWrite(4, HIGH);

35

Page 36: WPT FinalProgressReport

 } else  digitalWrite(4, LOW);  if(fsrReading1) {   pinMode(7, OUTPUT);   digitalWrite(7, HIGH); } else  digitalWrite(7, LOW);  if(fsrReading2) {   pinMode(12, OUTPUT);   digitalWrite(12, HIGH); } else  digitalWrite(12, LOW);  if(fsrReading3) {   pinMode(13, OUTPUT);   digitalWrite(13, HIGH); } else  digitalWrite(13, LOW);

// Serial.print("Analog reading = "); //Serial.println(fsrReading); //use this functions instead of analogWrite on 'initialized' pins // we'll need to change the range from the analog reading (0-1023) down to the range // used by analogWrite (0-255) with map! /*LEDbrightness = map(fsrReading, 0, 1023, 0, 255); // LED gets brighter the harder you press   analogWrite(LEDpin, LEDbrightness); //try pwmWrite

   delay(100);*/    int value = ( analogRead(analog_pin) + analogRead(analog_pin1) + analogRead(analog_pin2) + analogRead(analog_pin3) ) ; // for screen brightness it reads from pin 0 =A0 which gets input from fsr  map(value, 0, 1023, 0, 255); lcd.lcdSetBlacklight(value); delay(100);  randNumber = random(0, 100); //Serial.println(randNumber); x = String(randNumber); //Serial.println(x);  

36

Page 37: WPT FinalProgressReport

 x.toCharArray(y, 50); //Serial.println(y); delay(3000); buttons = lcd.readButtons(); buttons1 = buttons & 0x01; buttons2 = buttons & 0x002; buttons3 = buttons & 0x004; buttons4 = buttons & 0x008;  lcd.lcdGoToXY(1,1); if (!buttons) lcd.lcdWrite(" PRESS A BUTTON  TO SHOW PHONES ");   else if(!buttons1)  {   lcd.lcdWrite("PHONE1 320334111 IS CHARGED %");   lcd.lcdGoToXY(14,2); lcd.lcdWrite(y);}  else if(!buttons2)  {   lcd.lcdWrite("PHONE2 320334222 IS CHARGED %");   lcd.lcdGoToXY(14,2); lcd.lcdWrite(y);}  else if(!buttons3)  {   lcd.lcdWrite("PHONE3 320334333 IS CHARGED %");   lcd.lcdGoToXY(14,2); lcd.lcdWrite(y);}   else if(!buttons4) {   lcd.lcdWrite("PHONE4 320334444 IS CHARGED %");  lcd.lcdGoToXY(14,2); lcd.lcdWrite(y);} else   lcd.lcdWrite(" PRESS A BUTTON  TO SHOW PHONES ");

    delay(100);

 if ((fsrReading != 0 || fsrReading1 != 0) || (fsrReading3 != 0 || fsrReading2 != 0 ))  {   /* pwmWrite(led9, brightness);

 brightness = map(fsrReading2, 900, 1023, 120, 120); /*brightness + fadeAmount;

 if (brightness == 0 || brightness == 255) {   fadeAmount = -fadeAmount ;    }    */

37

Page 38: WPT FinalProgressReport

//delay(30);  pwmWrite(led10, 175);

/* brightness = brightness + fadeAmount;

 if (brightness == 0 || brightness == 255) {   fadeAmount = -fadeAmount ;      }      //delay(30);     /*pwmWrite(led3, brightness);

 brightness = brightness + fadeAmount;

 if (brightness == 0 || brightness == 255) {   fadeAmount = -fadeAmount ;      }      //delay(30);    */  }

else { //pwmWrite(led9, 0); pwmWrite(led10, 0); // pwmWrite(led3, 0);          }

}

38