Interactive light

 


 

Idea and Concept:

1. A light activated by human activities.

2. interactivity. interactive toy/product ....furniture

3. Run by itself (Pic)

Material: plastic

Location: Door way / Room

Activity:

When it stands alone , no light and movement

It activates when something gets close.

More movement and lighting when play with it.

========

IR Sensor (analog)--> PIC(analog) ----> LED & Step Motor(analog)



Code:

DEFINE OSC 4
DEFINE ADC_BITS 10
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 50

ADCvar VAR WORD
ADCvar2 VAR WORD
ADCvar3 VAR WORD
ADCvar4 VAR WORD

' set variables:
steps VAR WORD
stepArray VAR BYTE(4)
Clear

TRISA = %11111111
ADCON1 = %10000010

TRISD = %11110000
PORTD = 255

OUTPUT PORTC.3
OUTPUT PORTC.4
OUTPUT portb.6
OUTPUT portb.7
OUTPUT portb.5

stepArray[0] = %00001010
stepArray[1] = %00000110
stepArray[2] =%00000101
stepArray[3] = %00001001

PAUSE 500

main:

ADCIN 0, ADCvar ' Read channel 0 to adval
ADCIN 1, ADCvar2
ADCIN 2, ADCvar3
ADCIN 3, ADCvar4

if (ADCvar <40) AND (ADCvar2 < 40)AND (ADCvar3 < 40) AND (ADCvar4 <
40) then

LOW portc.3
LOW portc.4
LOW portb.6
LOW portb.7
LOW portb.5


ENDIF

if (ADCvar > 40) OR ( ADCvar2 > 40)OR(ADCvar3 >40)OR(ADCvar4 >40) then

High portb.5
high portc.3
low portc.4
High portb.6
LOW portb.7
steps = steps + 1
portD = stepArray[steps //4]

pause 4
ENDIF

if (ADCvar > 180) OR (ADCvar2 >180) OR(ADCvar3 >180)OR(ADCvar4 >180)
then

High portb.5
HIGH portc.3
High portc.4
High portb.6
high portb.7

steps = steps + 1
portD = stepArray[steps //4]


ENDIF

Serout2 PORTC.6, 16468, [DEC ADCvar, 13, 10] ' print it to serial out,
' with linefeed and carriage return (10, 13)


goto main




Movie file