Code used for the PIC16F88 logic:
'****************************************************************
'* Name: PIC PHOTO CODE*
'* Author: [Group 26] *
'* Notice: Copyright (c) 2016 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date: 10/18/2016 *
'* Version : 1.0 *
'* Notes : *
'* : *
'****************************************************************
'****************************************************************
'* Name: UNTITLED.BAS *
'* Author: [select VIEW...EDITOR OPTIONS] *
'* Notice: Copyright (c) 2016 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date: 10/18/2016 *
'* Version : 1.0 *
'* Notes : *
'* : *
'****************************************************************
#CONFIG
__CONFIG _CONFIG1, _INTRC_IO & _PWRTE_ON & _MCLR_OFF & _LVP_OFF
#ENDCONFIG
DEFINE OSC 8
OSCCON.4 = 1
OSCCON.5 = 1
OSCCON.6 = 1
ANSEL = 0 ' turns off the A/D converter
led1Var PORTB.4 ‘defines led1 to attach to PORTB.4
led2var PORTB.5 ‘defines led2 to attach to PORTB.5
led3var PORTB.3 ‘defines led3 to attach to PORTB.3
led4var PORTB.2 ‘defines led4 to attach to PORTB.2
Arduino var PORTB.1 ‘defines the port to communicate with Arduino
Photo Var PORTA.2 ‘defines Photoresistor to set bounds for lighting options
SCALE Con 511
pot_valVar BYTE
TRISA = %00000001 'sets AN0 as input and rest as outputs
TRISB = %00000000 'sets PORTB as all outputs
PORTB= %000000000 'sets all outputs of PORTB off to begin with
mainloop:
Do While (1)
POT Photo, SCALE, pot_val
If (pot_val >= 255) Then ‘if the resistor is greater than or equal to 255, then leave LED’s of
led1 = 0
led2 = 0
led3 = 0
led4 = 0
Arduino = 0
ElseIf (pot_val < 255) Then ‘if the resistor is less than 255, turn on the LED’s and send high to ‘Arduino
led1 = 1
led2 = 1
led3 = 1
led4 = 1
arduino = 1
EndIf
Loop ‘tells pic to keep on circling through the mainloop.