Final Project Journal

Project Ideation

1- Tell us about the idea of your project. Why do you care about this? What were you inspired by? Include images and videos of similar projects

I Love reading at night, but most of time I don't prefer the room light. sometimes, I had been lazy to switch lights on. So, I designed this box with light and potentiometer to control light intensity. with LCD to display the time.


Project Construction

2- Explain the CAD process of your project. How did you use the software to design your project? (List the softwares/tools/materials...etc that you used)

I wanted to have an enclosure for the electronics.

I divided the box into to sectiontions, onee for the electronics which is on the back side, and the other section for the led strip ( to avoid the electronics shadow on the lightness).

on the back I made it as strips to avoid heat on the electronics.

on the toop I needed slots for LCD, push button, potentiometer and slots for the other parts to fit in.

as for the right side, I needed slots for the on/off switch, power supply and arduino USB.

3- Explain the fabrication process of your project. How did you use the machine to fabricate your project? (List the softwares/tools/materials...etc that you used)

For the Laser cutting:

  1. open the flash memory on the laser cut PC.

  2. open my RLP file

  3. check the speed

  4. watch the preview

  5. prepare the origin position of the work piece

  6. checking the focal length by using the " focus".

  7. choose my file from the files

  8. RUN

Softwares:

  1. laser work software

Materials:

  1. wood sheets (3mm)

  2. acrylic sheet

Right part

the bottom and middle parts

Bacl part

Top and front parts

WhatsApp Video 2021-09-29 at 12.56.43 AM.mp4

Project Electronics & Power Management

4- Describe your electronic circuit. What are the input and action components? What is the function of each? How do the components integrate together to form your smart system? (List the softwares/tools/components...etc that you used)

software: Fritzing

components:

  1. arduino uno

  2. breadboard

  3. on/off switch (input)

  4. RTC DS3231 time module

  5. potentionmeter

  6. LCD 16*2 I2C

  7. buzzer

  8. H bridge

  9. led strip

  10. push button

  11. 12 v supply

  12. Jumpers

  13. wires

  14. 5 volt supply

Description:

the user pushes the on/off switch, the arduino and work, led strip will light. when the user pick alarm time, the buzzer will make sound. the user could control light with the potentionmeter.

5- What is your power source? How did you select the suitable power source for your project? (List the softwares/tools/components...etc that you used)

I used 5 volts adapter for the arduino and 12 volts adapter for the led strip to get high light intensity.

Project Programming

6- Describe the code of your project. How did you program each function of the project?

This code works with LCD, buzzer, RTC, led strip and potentiometer. this code displays current time and date on LCD, reading them by RTC module and control led strip intensity by the potentiometer.

Libiraries used in the code

#include <LiquidCrystal_I2C.h>

#include <MD_DS3231.h>

#include <MD_AButton.h>

#include <Wire.h>


// Define as 1 if alarm time to be initialised from variables, otherwise use RTC values

#define INIT_ALM_DEFAULTS 1


// Hardware definitions

#define BUZZER_PIN 2 // digital pin for tone buzzer



// Global objects

LiquidCrystal_I2C lcd(0x27, 16, 2); //adress for lcd I2C is 0x27


// Alarm setting registers

uint8_t almH = 15, almM = 28; // alm values, including defaults, here we can chnge the alarm where I wwanted to change this to use the push button instead, but it didn't work.

boolean almEnabled = true;

#define ALARM_ON_TYPE DS3231_ALM_HM // type of alarm set to turn on

#define ALARM_OFF_TYPE DS3231_ALM_DDHM // type of alarm set to turn off


// LCD characters to show alarm status

#define ALM_SET_CHAR 0x01

#define ALM_OFF_CHAR 0xdb

#define ALM_ON_CHAR 0x02


// Alarm state machine values

enum almFSM_t { AS_IDLE, AS_SETTING, AS_TRIGGERED };

almFSM_t almState = AS_IDLE;


void displayUpdate(void)

// Callback function for the RTC library

// Display the RTC values for time and alarm2

{

RTC.readTime();

printTime();

if (almState != AS_SETTING)

{

RTC.readAlarm2();

almH = RTC.h;

almM = RTC.m;

printAlarm();

}

}


void p2dig(uint8_t v)

// Print 2 digits with leading zero

{

if (v < 10) lcd.print("0");

lcd.print(v);

}


const char *dow2String(uint8_t code)

// Day of week to string. DOW 1=Sunday, 0 is undefined, it can be set by the set code in an example in DS3231 library. So,RTC will count normally after setting the current date and time.

{

static const char *str[] = {"---", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};


if (code > 7) code = 0;

return (str[code]);

}


void printAlarm(void)

// Display the alarm setting on the display

{

// Status indicator, it appears like black square when alarm is on and empty square when alarm is off.

lcd.setCursor(15, 0);

if (almState == AS_SETTING)

lcd.write((char)ALM_SET_CHAR);

else if (almEnabled)

lcd.write((char)ALM_ON_CHAR);

else

lcd.write((char)ALM_OFF_CHAR);


// Alarm time display on the LCD

lcd.setCursor(11, 1);

p2dig(almH);

lcd.print(":");

p2dig(almM);

}


void printTime(void)

// Display the current time on the LCD

{

// display the date and day

lcd.setCursor(0, 0);

lcd.print(dow2String(3));

lcd.print(" ");

lcd.print(RTC.yyyy);

lcd.print("-");

p2dig(RTC.mm);

lcd.print("-");

p2dig(RTC.dd);


// display the current time

lcd.setCursor(0, 1);

p2dig(RTC.h);

lcd.print(":");

p2dig(RTC.m);

lcd.print(":");

p2dig(RTC.s);

if (RTC.status(DS3231_12H) == DS3231_ON)

lcd.print(RTC.pm ? " pm" : " am");

}


void setMyAlarm(void)

// Set Alarm 2 values in the RTC

{

RTC.yyyy = RTC.mm = RTC.dd = 0;

RTC.h = almH;

RTC.m = almM;

RTC.s = RTC.dow = 0;

if (almEnabled)

RTC.writeAlarm2(ALARM_ON_TYPE);

else

RTC.writeAlarm2(ALARM_OFF_TYPE);

}


void doBuzzAlert()

// buzzer, to have tone when alam time is done.

{

tone(BUZZER_PIN, 523, 400);

delay(1000);

tone(BUZZER_PIN, 690, 400);

}

// the led strip code with the potentiometer

int in1 = 8; //Declaring where our module is wired

int in2 = 9;

int ConA = 10;// enable pin

int speed1;


void setup()

{

pinMode(3, INPUT_PULLUP); //push button

attachInterrupt(digitalPinToInterrupt(2), AddFifteen, FALLING);

pinMode(8, OUTPUT);

pinMode(9, OUTPUT);

pinMode(10, OUTPUT);

uint8_t c[8];


// initialise 16x2 LCD display shield

lcd.begin();

lcd.clear();

lcd.noCursor();


// create alarm status characters on LCD

c[0] = c[7] = 0x00;

c[1] = c[6] = 0x1f;

c[2] = c[3] = c[4] = c[5] = 0x15;

lcd.createChar(ALM_SET_CHAR, c);

c[2] = c[3] = c[4] = c[5] = 0x1f;

lcd.createChar(ALM_ON_CHAR, c);


// Buzzer

pinMode(BUZZER_PIN, OUTPUT);


// RTC global initialisation

RTC.control(DS3231_12H, DS3231_OFF); // 24 hour clock


// Alarm 1 - initialise the 1 second alarm for screen updates

RTC.setAlarm1Callback(displayUpdate);

RTC.setAlarm1Type(DS3231_ALM_SEC);


// Alarm 2 - initialise the alarm

#if INIT_ALM_DEFAULTS

setMyAlarm();

#else

RTC.setAlarm2Type(ALARM_OFF_TYPE);

#endif


almState = AS_IDLE;


displayUpdate();

}

void AddFifteen(){

almM= almM + 15;

}


void TurnMotorA() { //We create a function which control the led intensity


digitalWrite(in1, LOW); //Switch between this HIGH and LOW to change intensity

digitalWrite(in2, HIGH);

light = analogRead(A0);

light= light * 0.2492668622; //read thea analog value from the potentiometer calibrate it

analogWrite(ConA, light); // Then inject it to our led strip

}



void loop()

{


TurnMotorA(); //one function that keeps looping


char c = lcdKeys.getKey();


// screen update through callback every second

RTC.checkAlarm1();


// If the alarm has gone off, overrides any other state

if (RTC.checkAlarm2())


almState = AS_TRIGGERED;


switch (almState) // Alm Finite State Machine

{

case AS_IDLE: // IDLE state - usually in this state

switch (c)

{

case 'S': // Select has been pressed, ALM setting mode has been requested

almState = AS_SETTING;

RTC.readAlarm2(); // get the current values into the temp values, even if we do this every screen update

almH = RTC.h;

almM = RTC.m;

printAlarm();

break;


case 'U': // Up has been pressed, ALM on/off toggle

almEnabled = !almEnabled;

if (almEnabled)

RTC.setAlarm2Type(ALARM_ON_TYPE);

else

RTC.setAlarm2Type(ALARM_OFF_TYPE);

printAlarm();

break;

}

break;


case AS_SETTING: // SETTING state - process the keys

switch (c)

{

// Key - increment the alm minute

almM = (almM + 1) % 60;

printAlarm();

break;

}

break;


case AS_TRIGGERED: // TRIGGERED state - do whatever to signal alarm

doBuzzAlert();

almState = AS_IDLE;

break;


default:

almState = AS_IDLE;


}

}

Project Integration & Testing

7- Demonstrate with text and visuals how did you integrate the project’s modules together? What are the testing results? (Include a Demo video separately, showing a proof of functionality)

I divided the project into 2 parts, First one is connecting the potentionmeter and led strip together by the H-brige module,using the motor code. Second part is connecting LCD, buzzer and RTC module together. ( Cardboard)

Then, I integrated them together in the code and in the assembly and put them in the enclousre.

  • LCD:

  1. GND to GND

  2. VCC to 5V from the breadboard

  3. SDL to A4

  4. SCL to A5

  • potentiometer:

  1. VCC to 5v

  2. GND to GND

  3. third pin to A0

  • push button:

  1. black wire to GND

  2. wite wire to pin 3

  • on/off switch:

  1. wire to VCC pin in arduino

  2. wire to commen VCC in breadboard

  • H-bridge:

  1. 12V to 12V adapter

  2. GND to breadboard GND and 12V adapter -ve pin

  3. enable to pin 10

  4. IN1 to pin 9

  5. IN2 to pin 8

  6. OUT1 to +ve pin of led strip

  7. OUT2 to -ve pin of led strip

WhatsApp Video 2021-09-28 at 8.19.12 PM.mp4
WhatsApp Video 2021-09-28 at 8.29.06 PM.mp4

Sharing & Collaboration

8- Did you ask for feedback? What are the ideas that others have contributed or suggested? What was someone else’s idea that you built upon? How did you help your peers? How did your peers help you?

  • During the cardboard model stage, Amany advised me to design balde in the middle to cover the electronics to avoid having shadow on the front part.Also, she suggested the acrylic to be white to have better light distribution.

  • Sherief advised me to have all the power things ( switch, plug and arduino USB) in one side, specially the right side ( as majority of people use the right hand). Plus, suggesting the back to have open slots for the electronics to stay cool.

WhatsApp Video 2021-09-28 at 8.29.05 PM.mp4

Overcoming Challenges

9- When you got stuck, what/who did you turn to? At what point did you have to pause to research or learn more before moving on? What are some mistakes, pitfalls, or challenges that others can avoid if they were doing this project?

  1. acrylic was thicker than I expected, So I cut the base again.

  2. slots in the right side wasn't correct, S I used the mini drill lx134mo to reright it as possible as i could.

  3. Also, I got stuck in the code, So I've been researching for long time and instructor helpt me.


Future Work

10- If you had more time, what is one thing you would change/ Do next in your project?

modify the design and work more to code the timer push button

Final Project Design Files