Libelium is offering new technical support channels, to contact with de Technical Support team to solve any issue our doubt please contact with your sales agent or visit our contact site

Post a new topicPost a reply Page 1 of 1   [ 2 posts ]
Author Message
 Post subject: Music Shield
PostPosted: Mon Aug 29, 2011 4:55 am 

Joined: Mon Aug 29, 2011 4:45 am
Posts: 1
I bought a music shield from seedstudio and it works withoutproblem with an Mega320 with example code.

But if a want to make the classic alarm with a sensor, for example a PIR with a simple if of HIGH and LOW, doesnt work.

The sensor works and test in other programs, but it´s looks the the InitFileSystem(); and the Play();
ignores the sensor as if they are "//" the sensor works and make Serial.println but when they aren't I dont get any message.

Have anyone test this so simple thing and can help me, please

This is the sample code that work with just defining the input of the sensor and the if.

#include <avr/io.h>
#include "config.h"
#include "filesys.h"
#include "player.h"
#include "vs10xx.h"
#include "record.h"
#include <NewSoftSerial.h>
NewSoftSerial mySerial(2, 3);//pin2-Rx,pin3-Tx(note: pin3 is actually later used as volume down input)

int ledPin = 52; // choose the pin for the LED
int inputPin = 40; // choose the input pin (for PIR sensor)
int pirState = LOW; // we start, assuming no motion detected
int val = 0; // variable for reading the pin status

void setup()
Serial.println("Hello test!");
mySerial.begin(19200);// used for receiving command data from the iPod dock.

//Variables del PIR
pinMode(inputPin, INPUT);









void loop()

val = digitalRead(inputPin);
if (pirState == LOW) {



 Post subject: Re: Music Shield
PostPosted: Tue Aug 30, 2011 7:49 am 

Joined: Mon Sep 28, 2009 12:06 pm
Posts: 11366
Hi catsir,

Several things in your code:

- You read the value of the sensor, but in if sentence you don't use it, you use pirState
- Don't use while(1), the code won't go out from there.


Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 2 posts ]

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Libelium theme based on 610nm Style by Daniel St. Jules of

© Libelium Comunicaciones Distribuidas S.L. | Terms of use.