#define photo 0
#define LED 5
int val =
0
;
int ledState =
0
;
int counter =
0
;
void setup
(
)
{
Serial.begin
(
9600
)
;
pinMode
(
LED, OUTPUT
)
;
}
void loop
(
)
{
counter++;
if
(
counter
>
=
10000
)
{
updatePhoto
(
)
;
counter
=
0
;
}
if
(
Serial.available
(
)
>
0
)
{
//
read
the incoming byte
ledState = Serial.read
(
)
;
}
if
(
ledState ==
1
)
{
digitalWrite
(
LED, HIGH
)
;
}
else
{
digitalWrite
(
LED, LOW
)
;
}
//
delay
(
100
)
;
}
void updatePhoto
(
)
{
val = analogRead
(
photo
)
;
Serial.println
(
val
)
;
}