- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm trying to make a luxometer using PSOC 5LP CY8C5888LTI-LP097 with this code
#include <project.h>
#include <stdio.h>
#include <math.h>
int main()
{
uint8 i;
int Lux;
LCD_Start();
char8 publicar1 [22];
float32 conversion1,conversion2;
CyGlobalIntEnable;
ADC1_Start();
ADC1_StartConvert();
ADC1_IsEndConversion(ADC1_WAIT_FOR_RESULT);
for(;;)
{
LCD_PrintString("Int.Luminosa");
LCD_Position(1,8);
conversion1 = ADC1_GetResult16(0);
conversion2 = ((5.000000*conversion1)/1024)*0.232;
Lux = ((2500/conversion2)-500)/5;
LCD_PrintString("Lux");
LCD_PrintNumber(Lux);
LCD_Position(0,2);
CyDelay(200);
if(Lux>=51 && Lux <=200)
{
for(i=0;i<30;i+=2)
{
LCD_DrawHorizontalBG(1,0,2,i);
CyDelay(150);
}
LCD_ClearDisplay();
}
if(Lux>=202 && Lux <=350)
{
for(i=0;i<30;i+=2)
{LCD_DrawHorizontalBG(1,0,3,i);
CyDelay(150);
}
LCD_ClearDisplay();
}
if(Lux>=360 && Lux <=600)
{
for(i=0;i<30;i+=2)
{LCD_DrawHorizontalBG(1,0,4,i);
CyDelay(150);
}
LCD_ClearDisplay();
}
if(Lux>=620)
{
for(i=0;i<30;i+=2)
{LCD_DrawHorizontalBG(1,0,5,i);
CyDelay(150);
}
LCD_ClearDisplay();
}
}
}
and this is the diagram for the protoboard
and the ports P2[6:0] and P0[6]
please help