1 Reply Latest reply on Sep 24, 2020 6:44 AM by AH_96

    Let's make the dice of seven eyes on PSoC 6 with CapSense & sound,version 2

    NoTa_4591161

      Hi all,

      Through this programing of the dice, I was able to learn various PSoC designs. This time it is the modified version from Let's make the dice of seven eyes on PSoC 6 with CapSense & soundthe protagonist of the game. The PWM part is modified to swap.

      3.png  

      The environment used is as follows:

      PSoC Creator 4.2

      CY8CKIT-062-BLE

       

      The components are placed on the PSoC 6 kit so that sound and CapSense can be used. The decoding circuit has also been simplified. The circuit of PSoC6 is as follows.

        1.png

      The PWM_1 component settings are as follows. Checked “Enable Swap Period”.

      2.png

       

      The pin assignments are as follows.

      3.png

        4.png

       

       

      In the program, the PWM_1 component uses the period value swap. The program looks like this:

      if(!CapSense_IsBusy())
              {
                  CapSense_ProcessAllWidgets();
                  
                  if(sw==0){ // If sw is on, check start botton0.
                      if(CapSense_IsWidgetActive(CapSense_BUTTON0_WDGT_ID)) // Check button 0 state
                      {
                          /* Start rolling dice*/
                          PWM_1_SetCounter(0);
                          PWM_1_SetPeriod0(399);
                          PWM_1_SetPeriod1(999);
                          PWM_1_Start();  // Start rolling dice
                          sw=1; // sw is on
                      }
                  }
                  
                  if(sw==1){ // If sw is on, check stop botton0.
                      if(CapSense_IsWidgetActive(CapSense_BUTTON1_WDGT_ID)) // Check button 1 state
                      {
                          /* Roll dice slowly */
                          PWM_1_TriggerSwap();
                          CyDelay(1500); // keep rolling slowly for 1.5sec
                          PWM_1_Disable();// Stop rolling dice                    
                          sw=0;           // sw is off
                      }
                  }
                  
                  CapSense_UpdateAllBaselines();
                  CapSense_ScanAllWidgets(); // Start next scan
              } /* [] END OF FILE */
      

       

      Thanks,

      Kenshow