Let's make the dice of seven eyes using on PSoC 4 with a proximity sensor,version 2

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,

Through this programing of the dice, I was able to learn various PSoC designs. For more information on designing electronic dice, see the previous posts "PSoC 4 Seven Eyes Dice" and “PSoC 4 Seven Eyes Dice with sound”. This time it is the modified version. From the previous program “Let's make the dice of seven eyes using on PSoC 4 with a proximity sensorthe protagonist of the gam...”, the decoder part of the circuit is simplified and the PWM part is modified to swap. I will explain the changes here.

1.png

The environment used is as follows:

PSoC Creator 4.3

CY8CKIT-044

  • 1.  Change of decoding part

The simplified circuit of the decoding section is as follows. Two inverter logic have been deleted from the previous time.

1.png

  • 2.  PWM uses swap function

The PWM_1 component settings are as follows. Check the Swap of Period.

2.png

  • 3.  Program changes

Swap is performed at the timing of the S/W side.

:

       /* Enable and start PWM block. */

    PWM_2_Start();

    for(;;)

    {

        /* Update the baseline of the proximity sensor. */

              CapSense_UpdateSensorBaseline(CapSense_PROXIMITYSENSOR__PROX);

              /* Scan the proximity sensor. */

              CapSense_ScanSensor(CapSense_PROXIMITYSENSOR__PROX);

        while(CapSense_IsBusy())

              {

                     /* Put the PSoC 4200M in Sleep power mode while the CapSense is scanning.

                      * The device wakes up using the interrupt generated by CapSense CSD Component

                      * after scanning. */

              }

              /* Check if proximity sensor is active. */

              proximity = CapSense_CheckIsSensorActive(CapSense_PROXIMITYSENSOR__PROX);

              if(proximity == ACTIVE)

              {

                     /* Set the LED at a brightness level corresponding

                      * to the proximity distance. */

            if(sw==0){

                PWM_1_WritePeriodBuf(999);

                PWM_1_WritePeriod(399);

                PWM_1_WriteCounter(0);

                PWM_1_Start();  // Start rolling dice

                sw=1;

            }

        }

              else /* Proximity sensor is inactive. */

              {

            if(sw==1){

                /* Roll dice slowly */

                PWM_1_TriggerCommand(1, PWM_1_CMD_CAPTURE);

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

                PWM_1_Stop();// Stop rolling dice                   

                sw=0;           // sw is off   

            }

              } 

    }

          :

When you bring your hand closer, the dice rotate, and when you move away, the rotation slows down and stops.

Thanks,

Kenshow

3 Replies
BragadeeshV
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hi NoTa_4591161san,

Looks interesting! Thanks for your contribution

Regards,

Bragadeesh

Regards,
Bragadeesh

Bragadeesh,

It's not me.

Regards,

Noriaki

0 Likes
BragadeeshV
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

NoriakiT_91​-san, Sorry for the confusion. I've edited my previous response. Thanks for pointing it out!

Regards,

Bragadeesh

Regards,
Bragadeesh
0 Likes