Documente Academic
Documente Profesional
Documente Cultură
Submitted By:
Bautista, Ian Steven T.
CPE51
Submitted To:
Engr. Ferdinand Osorio
Materials
PSoC 5LP
Connecting wires
5 - LEDs
5 - 100 ohms resistor
Circuit
Condition
If the CapSense is touched from right to left, then LED is ON from right to left.
Then from left to right, then LED is OFF from left to right.
Top Design
Pin Assignment
Codes
#include <project.h> LCD_Char_1_Position(0,0);
uint8 x; LCD_Char_1_PrintInt8(x);
int y,z; if(x==255){
Pin_3_Write(0);
int main() Pin_4_Write(0);
{ Pin_5_Write(0);
CyGlobalIntEnable; /* Enable global Pin_6_Write(0);
interrupts. */ Pin_7_Write(0);
CapSense_1_Start(); }
LCD_Char_1_Start();
CapSense_1_InitializeAllBaselines(); if (x>0 && x<20)
{
a: y=1;
z=1;
CapSense_1_UpdateEnabledBaselines( }
); if (x>20 && x<40 &&z)
CapSense_1_ScanEnabledWidgets(); {
while(CapSense_1_IsBusy()!=0){ y=2;
} if(x==255)
z=0;
if(CapSense_1_CheckIsWidgetActive(C }
apSense_1_BUTTON0__BTN)) if (x>40 && x<60 &&z)
{ {
Pin_1_Write(1); y=3;
} if(x==255)
else{ z=0;
Pin_1_Write(0); }
} if (x>60 && x<80 &&z)
{
if(CapSense_1_CheckIsWidgetActive(C y=4;
apSense_1_BUTTON1__BTN)) if(x==255)
{ z=0;
Pin_2_Write(1); }
} if (x>80 && x<99 &&z)
else{ {
Pin_2_Write(0); y=5;
} if(x==255)
z=0;
x=CapSense_1_GetCentroidPos(CapSe }
nse_1_LINEARSLIDER0__LS); if (x==255)
{ if (y==4)
y=0; {
z=0; Pin_3_Write(1);
} Pin_4_Write(1);
if (x==100) Pin_5_Write(1);
{ Pin_6_Write(1);
y=0; Pin_7_Write(0);
z=0; }
} if (y==5)
if (y==1) {
{ Pin_3_Write(1);
Pin_3_Write(1); Pin_4_Write(1);
Pin_4_Write(0); Pin_5_Write(1);
Pin_5_Write(0); Pin_6_Write(1);
Pin_6_Write(0); Pin_7_Write(1);
Pin_7_Write(0); }
}
if (y==2) goto a;
{
Pin_3_Write(1);
Pin_4_Write(1);
Pin_5_Write(0); /* Place your initialization/startup
Pin_6_Write(0); code here (e.g. MyInst_Start()) */
Pin_7_Write(0);
} for(;;)
if (y==3) {
{ /* Place your application code here.
Pin_3_Write(1); */
Pin_4_Write(1); }
Pin_5_Write(1); }
Pin_6_Write(0);
Pin_7_Write(0); /* [] END OF FILE */
}