Let's make the dice of seven eyes on PSoC 4 with sound,the protagonist of the game

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Kenshow
Level 8
Level 8
Distributor - Marubun (Japan)
50 solutions authored 25 solutions authored 10 solutions authored

Hi all,

The electronic dice I posted last time was very popular. Many people have requested that we make on PSoC 4 version, so I made it based on CY8CKIT-044. See previous post for more details on the design of the "PSoC 4 Seven Eyes Dice". Here, I will describe the addition of the design for sounding the piezoelectric buzzer.

1.png  

The environment used is as follows:

PSoC Creator 4.3

CY8CKIT-044

PWM (PWM_2) and piezoelectric buzzer (external) were added to the previous circuit. The circuit of PSoC4 is as follows.

2.png

 

The pin assignments are as follows.

3.png

 

The added PWM_2 inputs a 1MHz clock, and the settings are as follows.

4.png 

The program adds a start API for PWM_2.

#include "project.h"

uint32_t sw=0;  //sw is off (Stop rolling dicce)

int main(void)

{

    CyGlobalIntEnable; /* Enable global interrupts. */

    /* Place your initialization/startup code here (e.g. MyInst_Start()) */

    PWM_2_Start();

    for(;;)

    {

       if(sw==0){

           // if(Cy_GPIO_Read(SW2_PORT,SW2_NUM)==0){

            if(SW2_Read()==0){

                PWM_1_WritePeriod(400);

                PWM_1_WriteCounter(0);

                PWM_1_Start();  // Start rolling dice

                sw=1;

            }

        }

        if(sw==1){

            //if(Cy_GPIO_Read(SW2_PORT,SW2_NUM)==1){

            if(SW2_Read()==1){

                /* Roll dice slowly */

                PWM_1_WritePeriod(1000);

                PWM_1_WriteCounter(0);

                CyDelay(1500);  // keep rolling slowly for 1.5sec

                PWM_1_Stop();// Stop rolling dice                   

                sw=0;           // sw is off           

            }

        }

    }

}

Thanks,

Kenshow

1 Reply
Hari
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hi Kenshow-san,

Thank you for sharing your example project with the community.

Best regards,
Hari

0 Likes