mgfelettronica
Joined: 25 Jun 2012 Posts: 1
|
Level sensor with pic12F1822 |
Posted: Tue Jun 26, 2012 10:11 am |
|
|
Hi, I must to do a level sensor for a bottle.
I would like to use the mtouch system.
For first thing, I write this program below: it is for a simple keypad. When the water in the bottle reaches the sensor, the led switch on for 100ms and after switch off.
Now, I need that when the water reach the level of my sensor, the output must to stay on and it must to switch off only when the level of water drops under the sensor. Is possible to do it with ccs library?
I have the PCWHD compiler 4.120 version.
Best regards,
pietro
Code: |
#include "12F1822.H"
#use fast_io(A)
#fuses INTRC_IO,MCLR,NOWDT,NOPROTECT,PUT,BROWNOUT
#use delay(clock=8000000)
#USE TOUCHPAD (THRESHOLD=5, PIN_A2='5')
#define CY_OFF output_high(PIN_A4)
#define CY_ON output_low(PIN_A4)
void main(void)
{
unsigned int8 c=0;
//port_a_pullups (0xFF);ATTENZIONE! se si mette il pullup sul pin del touch non funziona piĆ¹!
set_tris_a(0b00000100);//RA2 input
TOUCHPAD_STATE(1);
enable_interrupts(GLOBAL);
delay_ms(500);
for(;;)
{
while(TOUCHPAD_HIT())
{
if(touchpad_getc()=='5')
CY_ON;
delay_ms(100);
}
CY_OFF;
}
} |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Jun 26, 2012 2:16 pm |
|
|
I think you are asking if the CCS touchpad library can do more than just
detect a keypress event. You want to know if it can detect keydown (or
hold), and key release events.
For example, AN1202 describes "continuous touch" detection:
http://ww1.microchip.com/downloads/en/AppNotes/01202A.pdf
Based on the description in the CCS manual, the CCS library only
supports a keypress event. You would have to write your own driver
(or translate Microchip driver code) to get your desired featues. |
|