Edgar Andrade
Published

Automatic Pet Food Dispenser

A dispenser that provides a pet's daily necessary food automatically.

BeginnerFull instructions provided2 hours977
 Automatic Pet Food Dispenser

Things used in this project

Story

Read more

Schematics

TopDesign.cysh

Code

Untitled file

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>

/* LED control defines (active low)*/

#define LIGHT_ON                        (0u)

/* Selects the active blinking LED */
uint8 activeLed;
uint8 flag; 
uint8 flag2; 

/*******************************************************************************
* Defines the interrupt service routine and allocates a vector to the interrupt.
* We use one handler for both the Capture and Terminal Count interrupts
* We toggle the active LED upon each Terminal Count interrupt
* We toggle the color (active LED) between blue and green upon each Capture 
* interrupt
********************************************************************************/
CY_ISR(InterruptHandler)
{
     flag++;
    if(flag==3){
    flag=0;
    }
     /* Clear interrupt and then process Terminal Count interrupt */
     Timer_ClearInterrupt(Timer_INTR_MASK_TC);
    LED_BLUE_Write(~LED_BLUE_Read());
    if (flag==1){
     PWM_Start();
     PWM_WritePeriod(20000);
     PWM_WriteCompare(1400); 
     
    
   
        
    }
     if (flag==0){
    
     PWM_WritePeriod(20000);
     PWM_WriteCompare(400); 
    
     
        
    }
     if (flag==2){
     
     PWM_WritePeriod(20000);
     PWM_WriteCompare(2400); 
    
   
    
        
    }

  



    
}

int main()
{    
     //LED_BLUE_Write(LIGHT_ON);
     flag =0;
     PWM_Start();
     PWM_WritePeriod(20000);
     PWM_WriteCompare(400); 

   
    #if (CY_PSOC4_4000)
        CySysWdtDisable();
    #endif /* (CY_PSOC4_4000) */
       
    /* Enable global interrupt */
    CyGlobalIntEnable;
    
    /* Enable interrupt component connected to interrupt */
    TC_CC_ISR_StartEx(InterruptHandler);

    /* Start components */
    Timer_Start();

    for(;;)
    {
        /* Capture signal generation */
        /* We emulate utton press. Real button can be used instead. */
        
        
        /* Keep pulse high for some time*/
        
        
        /* Go back to low signal */
        
        
        /* Capture signal will be generated for each 3s */
        
    }
}


/* [] END OF FILE */

Credits

Edgar Andrade

Edgar Andrade

1 project • 0 followers

Comments