CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Problem with capsense

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
marcudan



Joined: 01 Dec 2012
Posts: 2

View user's profile Send private message

Problem with capsense
PostPosted: Sat Dec 01, 2012 3:05 pm     Reply with quote

I'm trying to make the LED (pin_a6) to light while I'm with the finger on the button (c == 'V') but it's not working.
Please help me.
Code:

#include <16F1827.h>
#fuses INTRC_IO,NOWDT,NOPROTECT,NOMCLR
#use delay (internal=8000000)
#use fast_io (A)             

#use touchpad(scantime=40ms,threshold=6,RANGE=H,PIN_B1='J',PIN_B2='X',PIN_B3='S',PIN_B4='A',PIN_B5='V')


void main()
{
set_tris_a(0X00);
setup_adc_ports(NO_ANALOGS);
delay_ms(500);

output_low(PIN_A0);
output_low(PIN_A1);
output_low(PIN_A2);
output_low(PIN_A3);
output_low(PIN_A4);
output_low(PIN_A5);
output_low(PIN_A6);
output_low(PIN_A7);
char k=0;
char c=0;

enable_interrupts(GLOBAL);
TOUCHPAD_STATE(1);

while(TRUE)
   {
   delay_ms(300);
   c=0;

   if (k==0)
       k=1;
       
   if (k==5)
       k=4;
   
   if (k==1)
     { output_low(PIN_A7);
       output_low(PIN_A4);
       output_low(PIN_A3);
       output_low(PIN_A2);
     }
   if (k==2)
     { output_high(PIN_A7);
       output_high(PIN_A4);
       output_low(PIN_A3);
       output_low(PIN_A2);
     }
   if (k==3)
     { output_high(PIN_A7);
       output_high(PIN_A4);
       output_high(PIN_A3);
       output_low(PIN_A2);
     }
   if (k==4)
     { output_high(PIN_A7);
       output_high(PIN_A4);
       output_low(PIN_A3);
       output_high(PIN_A2);
     }
     
     //c=0;

      if(touchpad_hit())
      {
         c=touchpad_getc();
      }
     
      if (c=='J')
      {
       k=k-1;
       delay_ms(300);
      }
     
      if (c=='S')
      {
       k=k+1;
       delay_ms(300);
      }
     
      if (c=='A')
      {
       output_high(PIN_A1);
       delay_ms(1000);
      }
     
      if (c=='X')
      { 
       output_high(PIN_A0);
       delay_ms(1000);
      }

      if (c=='V')
      {
       output_high(PIN_A6);
    //  while (c!='V');
      delay_ms(1000);
       }
   
      output_low(PIN_A0);
      output_low(PIN_A1);
      output_low(PIN_A6);
   
      }   
}
rodrigo.bzsilva



Joined: 13 Nov 2012
Posts: 4

View user's profile Send private message Visit poster's website

Re: Problem with capsense
PostPosted: Thu Dec 06, 2012 5:56 am     Reply with quote

Hi, post a description of your hardware and your CCS compiler version.

I suggest that remove the directive "#use fast_io (A)" and "set_tris_a(0X00)". The CCS Compiler normally creates automatic settings for such functions used.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group