element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Cypress Kits
  • Products
  • Dev Tools
  • Cypress Kits
  • More
  • Cancel
Cypress Kits
Forum PSoC 4 Pioneer Kit Community Project#02 - CapSense Slider
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Cypress Kits to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 23 replies
  • Subscribers 26 subscribers
  • Views 3865 views
  • Users 0 members are here
  • 100projects
Related

PSoC 4 Pioneer Kit Community Project#02 - CapSense Slider

cy.gul
cy.gul over 12 years ago

On the 2nd day of our 100 Projects in 100 Days community effort, I am posting one of the PSoC 4 Pioneer Kit's bundled example projects.

 

This is a very simple yet effective CapSenseRegistered demo that implements a 5-segment slider, like the one available on the Pioneer kit.

Moving your finger across the capacative touch slider on the board, you will observe the multicolor LEDs gradually changing color from red to green. These LEDs are driven by the PWM Component.

 

 

Project Schematic:

image

                            (Actual PSoC Creator project schematic "TopDesign.cysch")

 

image

    (CapSense Component Customizer - Implementing a Capacitive Touch Slider)



Hardware Connections (all internal to the board, no external connections required):

  • 5-segment Slider - P1[1] - P1[5]
  • Green LED - P0[2]
  • Red LED - P1[6]

 

Software Setup:

  • See steps #1 - #6 from the main post here
  • Main.C - This example project implement simple firmware in the project's main.c as shown below (already completed in the example project). The code implmented scans the CapSense slider, then updates the PWM's PulseWidth with the slider value.

image

                                      ( Project firmware - main.c )


Demo Video

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

Project Files:

  • CapSense.cywrk.Archive01.zip

 

 


Attachments:
CapSense.cywrk.Archive01.zip
CapSense_Configuration.zip
  • Sign in to reply
  • Cancel

Top Replies

  • Former Member
    Former Member over 11 years ago +1
    good~!
  • Former Member
    Former Member over 12 years ago

    Hi,

    Following the example,I write the code to build a CapSense project in PSOC Creat 2.2 SP1,but find there are some errors,such as undefined reference to "PWMWriteCompae";

    Could you tell me the possible cause of these errors and help me to solve it?

    Thank you very much.

     

    image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 12 years ago in reply to Former Member

    Attach the .ZIP-file here and upload the project

    Attachments:
    p4-capsense-1.cywrk.Archive02.zip
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 12 years ago in reply to Former Member

    Now I can build it succesfully.I need to write the right API function name,pay attention to the big or small letter.

    Thanks

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 12 years ago in reply to Former Member

    Good to hear, Gui.

    Antonio

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 12 years ago in reply to Former Member

    Thank you very much!

    Could you explain,in more detail,why the multicolor LEDs will gradually change color from red to green?

    After use PWM_WriteCompare() function to update the PWM pulse width with the new slider position,how does the waveform of the PWM's output(line&line_n changes)?

    Thanks

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • cy.gul
    cy.gul over 12 years ago in reply to Former Member

    Hi Gui Zhao,

    By using the PWM_WriteCompare() API, you are effectively re-configuring the PWM Component's properties during run-time.

    By writing a new compare value each time with the slider position, the duty cycle of the PWM changes, which in-turn modifies the LED outputs.

    In our project, the PWM Component has 2 outputs, "line" and "line_n" - which are nothing but the inverse of each other (the sum total of these 2 outputs is thereby 100% duty cycle).

    "line" is connected to the Red LED while "line_n" (inverse) is connected to the Green LED.

    As you adjust the duty cycle of one of PWM outputs by writing a new compare value, the other one inversely changes. Thus, you are going from 0-100% duty cycle on one LED, and the opposite on the 2nd LED. The result to the naked eye is a gradual change between the LED output between Red and Green colors.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 11 years ago

    good~!

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 11 years ago

    Hi Im new to any sort of embedded programming but want to give it a go and get stuck in.

    I have the PSoC 4 pioneer kit and am trying to do these tutorials.

    I have tried to do this one however keep getting stuck.

    I have wrote the source code and built it and programmed it all onto the board with no errors showing up in the creator.

    However I just have a constant yellowish light on and the slider doesnt do anything.

    Was wondering if anyone else has encountered this problem or could suggest solutions.

     

    Cheers in advance

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • cy.gul
    cy.gul over 11 years ago in reply to Former Member

    HI George,

    This could be because you haven't assigned the CapSense slider to specific IO pins.

    You can do this by opening the "<project_name.CYDWR>" file from the project explorer.

    • 5-segment Slider - P1[1] - P1[5]
    • Green LED - P0[2]
    • Red LED - P1[6]
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 11 years ago in reply to cy.gul

    Hi Gagan,

    By using the PWM_WriteCompare() API,the compare value has changed, I think it should be less than period value(The period value don't change).

    But I found you didn't care about that in the program.It seems that compare value is large than period value.Would you tell me the reason?

    Thanks

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube