Shahariar
Published © GPL3+

PSoC 4: Alarm System for Kitchen Safety

Detects leakage of Natural Gas from stoves, and gas lines inside a kitchen and generates audio visual alerts.

BeginnerFull instructions provided4 hours2,019
PSoC 4: Alarm System for Kitchen Safety

Things used in this project

Hardware components

PSoC 4 Prototyping Kit
Cypress PSoC 4 Prototyping Kit
×1
Breadboard (generic)
Breadboard (generic)
×1
RGY Segment LED Bar/Dash Display
×1
Seeed Studio Grove Gas Sensor MQ5
×1
SparkFun Piezo
×1

Software apps and online services

PSoC Creator
Cypress PSoC Creator

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Seeed Studio Jumper wire

Story

Read more

Schematics

PSoC Internal & External Sch

Code

C Code

C/C++
/* ========================================
 *
 * Copyright YOUR COMPANY, THE YEAR
 * All Rights Reserved
 * UNPUBLISHED, LICENSED SOFTWARE.
 *
 * CONFIDENTIAL AND PROPRIETARY INFORMATION
 * WHICH IS THE PROPERTY OF your company.
 *
 * ========================================
*/
#include <project.h>

int Val=0;
int slope=0;
// Fn Def
void Level_7(void);
void Level_6(void);
void Level_5(void);
void Level_4(void);
void Level_3(void);
void Level_2(void);
void Level_1(void);
void Level_Off(void);


int main()
{
uint16_t gaslevel=0;
int i;
    ADC_Start();
    Opamp_Start();
    IDAC_Start();
    
    //// DONT FORGET TO START EVERY HARDWaaaaaaa //
    
    
ADC_StartConvert();
IDAC_Start();
for(i=0;i<10;i++)
{
Level_7();
CyDelay(200);
Level_Off();
CyDelay(200);
}
    /* CyGlobalIntEnable; */ /* Uncomment this line to enable global interrupts. */
    for(;;)
    {
        /* Place your application code here. */
while(ADC_IsEndConversion(ADC_RETURN_STATUS)){}
gaslevel=ADC_GetResult16(0);


if (gaslevel>0&&gaslevel<600)
{   Level_1();}
else if (gaslevel>=600&&gaslevel<900)
{   Level_2();}
else if (gaslevel>=900&&gaslevel<1200)
{   Level_3();}
else if (gaslevel>=1200&&gaslevel<1800)
{   Level_4();}
else if (gaslevel>=1800&&gaslevel<2400)
{   Level_5();
IDAC_SetValue(Val);Val=Val+15;if(Val>255){Val=0;}
}
else if (gaslevel>=2400&&gaslevel<3000)
{   Level_6();
IDAC_SetValue(Val);Val=Val+20;if(Val>255){Val=0;}
}
else if(gaslevel>3000)
{   Level_7();
IDAC_SetValue(Val);Val=Val+25;if(Val>255){Val=0;}
}
    
}
}
///////////////////////////////////////////
///////////////////////////////////////////
// ROUTINES //

void Level_7(void)
{
  //  CyDelay(1);
LED_G1_Write(0);
LED_G2_Write(0);
LED_G3_Write(0);
LED_Y1_Write(0);
LED_Y2_Write(0);
LED_R1_Write(0);
LED_R2_Write(0);
   // CyDelay(1); 
}


void Level_6(void)
{
   //  CyDelay(1);
LED_G1_Write(0);
LED_G2_Write(0);
LED_G3_Write(0);
LED_Y1_Write(0);
LED_Y2_Write(0);
LED_R1_Write(0);
LED_R2_Write(1);
   //  CyDelay(1);
}


void Level_5(void)
{
     CyDelay(1);
LED_G1_Write(0);
LED_G2_Write(0);
LED_G3_Write(0);
LED_Y1_Write(0);
LED_Y2_Write(0);
LED_R1_Write(1);
LED_R2_Write(1);
     CyDelay(1);
}

void Level_4(void)
{
     CyDelay(1);
LED_G1_Write(0);
LED_G2_Write(0);
LED_G3_Write(0);
LED_Y1_Write(0);
LED_Y2_Write(1);
LED_R1_Write(1);
LED_R2_Write(1);
 CyDelay(1);   

}


void Level_3(void)
{
     CyDelay(1);
LED_G1_Write(0);
LED_G2_Write(0);
LED_G3_Write(0);
LED_Y1_Write(1);
LED_Y2_Write(1);
LED_R1_Write(1);
LED_R2_Write(1);
     CyDelay(1);
}

void Level_2(void)
{
     CyDelay(1);
LED_G1_Write(0);
LED_G2_Write(0);
LED_G3_Write(1);
LED_Y1_Write(1);
LED_Y2_Write(1);
LED_R1_Write(1);
LED_R2_Write(1);
     CyDelay(1);
}

void Level_1(void)
{
     CyDelay(1);
LED_G1_Write(0);
LED_G2_Write(1);
LED_G3_Write(1);
LED_Y1_Write(1);
LED_Y2_Write(1);
LED_R1_Write(1);
LED_R2_Write(1);
     CyDelay(1);
}
void Level_Off(void)
{
     CyDelay(100);
LED_G1_Write(1);
LED_G2_Write(1);
LED_G3_Write(1);
LED_Y1_Write(1);
LED_Y2_Write(1);
LED_R1_Write(1);
LED_R2_Write(1);
 CyDelay(100);
    
}
    

/* [] END OF FILE */

PSoC Files

C/C++
No preview (download only).

Credits

Shahariar

Shahariar

74 projects • 265 followers
"What Kills a 'Great life' is a 'Good Life', which is Living a Life Inside While Loop"

Comments