I m creating a visual C++ application. This application will switch on the light automatically for 30min after the motion sensor has detected the motion. If the detection still continue after 30min. Then the light will still ON.
2. this application connects to the PIC circuit.
Hope to hear from u all soon~ thanks a lot
if(WriteFile(WriteHandleToUSBDevice, &OUTBuffer, 65, &BytesWritten, 0)) // Blocking function, unless an "overlapped" structure is used
{
// Now get the response packet from the firmware.
INBuffer[0] = 0;
if(ReadFile(ReadHandleToUSBDevice, &INBuffer, 65, &BytesRead, 0)) // Blocking function, unless an "overlapped" structure is used
{
// INBuffer[0] is the report ID, which we don't care about.
// INBuffer[1] is an echo back of the command (see microcontroller firmware).
// INBuffer[2] contains the I/O port pin value for the LDR sensor state (see microcontroller firmware).
if((INBuffer[1] == 0x87) && (INBuffer[2] == 0x01))
{
Dark2 = FALSE;
}
if((INBuffer[1] == 0x87) && (INBuffer[2] == 0x00))
{
Dark2 = TRUE;
}
}
} This code is used to detect the motion sensor
if(WriteFile(WriteHandleToUSBDevice, &OUTBuffer, 65, &BytesWritten, 0)) // Blocking function, unless an "overlapped" structure is used
{
// Now get the response packet from the firmware.
INBuffer[0] = 0;
if(ReadFile(ReadHandleToUSBDevice, &INBuffer, 65, &BytesRead, 0)) // Blocking function, unless an "overlapped" structure is used
{
// INBuffer[0] is the report ID, which we don't care about.
// INBuffer[1] is an echo back of the command (see microcontroller firmware).
// INBuffer[2] contains the I/O port pin value for the pushbutton (see microcontroller firmware).
if((INBuffer[1] == 0x88) && (INBuffer[2] == 0x01))
{
LEDstate2 = TRUE;
}
if((INBuffer[1] == 0x88) && (INBuffer[2] == 0x00))
{
LEDstate2 = FALSE;
}
}
} This is manual on and off code
2. this application connects to the PIC circuit.
Hope to hear from u all soon~ thanks a lot
if(WriteFile(WriteHandleToUSBDevice, &OUTBuffer, 65, &BytesWritten, 0)) // Blocking function, unless an "overlapped" structure is used
{
// Now get the response packet from the firmware.
INBuffer[0] = 0;
if(ReadFile(ReadHandleToUSBDevice, &INBuffer, 65, &BytesRead, 0)) // Blocking function, unless an "overlapped" structure is used
{
// INBuffer[0] is the report ID, which we don't care about.
// INBuffer[1] is an echo back of the command (see microcontroller firmware).
// INBuffer[2] contains the I/O port pin value for the LDR sensor state (see microcontroller firmware).
if((INBuffer[1] == 0x87) && (INBuffer[2] == 0x01))
{
Dark2 = FALSE;
}
if((INBuffer[1] == 0x87) && (INBuffer[2] == 0x00))
{
Dark2 = TRUE;
}
}
} This code is used to detect the motion sensor
if(WriteFile(WriteHandleToUSBDevice, &OUTBuffer, 65, &BytesWritten, 0)) // Blocking function, unless an "overlapped" structure is used
{
// Now get the response packet from the firmware.
INBuffer[0] = 0;
if(ReadFile(ReadHandleToUSBDevice, &INBuffer, 65, &BytesRead, 0)) // Blocking function, unless an "overlapped" structure is used
{
// INBuffer[0] is the report ID, which we don't care about.
// INBuffer[1] is an echo back of the command (see microcontroller firmware).
// INBuffer[2] contains the I/O port pin value for the pushbutton (see microcontroller firmware).
if((INBuffer[1] == 0x88) && (INBuffer[2] == 0x01))
{
LEDstate2 = TRUE;
}
if((INBuffer[1] == 0x88) && (INBuffer[2] == 0x00))
{
LEDstate2 = FALSE;
}
}
} This is manual on and off code