Red Jungle Fowl [VEML7700]
Connecting the VEML7700
3.3V [3.3V]
GND [- / GND]
SDA [P20]
SCL [P21]
Connecting the LEDs
+ [P8]
- [100Ω and Ground]
Connecting the MP3 Player
Power can be connected to the breadboard power rails if required. But for this setup, Power is connected directly to the VCC and Ground is connected directly to the GRD of MP3 Player. TX is connected to [P10] while RX is connect to [P11].
The Arduino Code
The arduino code has been included in the file. Or provided below.
You will also need DFRobot VEML7700 and Serial MP3 library.
#include <Wire.h>
#include "DFRobot_VEML7700.h"
#include "SerialMP3Player.h"
#define TX 11
#define RX 10
SerialMP3Player mp3(RX,TX);
DFRobot_VEML7700 als;
void setup()
{
Serial.begin(9600);
mp3.begin(9600); // start mp3-communication
delay(500); // wait for init
mp3.sendCommand(CMD_SEL_DEV, 0, 2); //select sd-card
delay(500);
als.begin();
pinMode(8, OUTPUT);
// mp3.pause();
}
void loop()
{
float lux;
// mp3.pause();
als.getALSLux(lux);
Serial.print("Lux:");
Serial.print(lux);
Serial.println(" lx");
delay(200);
if(lux < 18){
digitalWrite(8, HIGH);
mp3.play(); // Play "hello.mp3". You must hear "Hello World"
delay(100); // wait 3 seconds
}
if(lux > 19){
digitalWrite(8, LOW);
mp3.reset(); // Play "hello.mp3". You must hear "Hello World"
delay(100); // wait 3 seconds
}
}