Australia
New Zealand
www.jaycar.com.au
www.jaycar.co.nz
1800 022 888
0800 452 922
Page
2
of
2
XC3920 User Guide
Lilypad Plus Quick Start
Upload the following code and open the
Serial Monitor
with baud
9600
Change the board under Tools > Board to
LilyPad Arduino
USB
Change the port to be the port of your connected Lilypad Board.
#include
<Adafruit_NeoPixel.h>
#define
LIGHT_SENSOR A5
#define
TEMP_SENSOR A0
#define
TOGGLE_SWITCH
21
#define
BUTTON_A
4
#define
BUTTON_B
19
#define
BUZZER
5
//10 leds on pin 17
Adafruit_NeoPixel
leds(
10
,
17
, N NEO_KHZ800);
int
counter =
0
;
void
setup()
{
Serial
.
begin
(
9600
);
leds.
begin
();
leds.show();
leds.setBrightness(
50
);
pinMode(BUZZER, OUTPUT);
pinMode(BUTTON_A, INPUT_PULLUP);
pinMode(BUTTON_B, INPUT_PULLUP);
pinMode(LIGHT_SENSOR, INPUT);
pinMode(TEMP_SENSOR, INPUT);
pinMode(TOGGLE_SWITCH, INPUT);
}
void
loop()
{
//for each colour of the rainbow ( Look at the original Neopixel example)
for
(
long
first =
0
; first <
5
*
65536
; first +=
256
)
{
//set every pixel to be a portion of the rainbow
for
(
int
i =
0
; i < leds.numPixels(); i++)
leds.setPixelColor(i, leds.gamma32(leds.
ColorHSV
(first +
(i *
6553L
))));
leds.show();
// Update leds with new contents
if
(counter >
10
)
{
Serial
.
(
"Temperature Reading: "
);
Serial
.println(analogRead(TEMP_SENSOR));
Serial
.
(
"Light Reading:"
);
Serial
.println(analogRead(LIGHT_SENSOR));
Serial
.
(
"Button Status: "
);
Serial
.
(digitalRead(BUTTON_B)
?
"[B] "
:
""
);
Serial
.
(digitalRead(BUTTON_A)
?
"[A] "
:
""
);
Serial
.
(
"Switch: ["
);
Serial
.
(digitalRead(TOGGLE_SWITCH)
?
"HIGH"
:
"LOW"
);
Serial
.println(
"]"
);
Serial
.println(
"------------------------------------"
);
counter =
0
;
}
else
{
+;
}
delay(
10
);
}
for
(
int
i =
0
; i <
10
; i++)
{
tone(BUZZER,
200
+
(
40
* i));
delay(
100
);
}
noTone(BUZZER);
}