Blog
Write a new blog entry

MP3 Shield (geeetech)
created: 05 Jul 2013 04:22
tags:
VS1053 MP3 Shield by geeetech. Here's a basic code for stop & playing music.

mp3%20shield.JPG
Geeetech MP3 Shield here in Arduino Lab - Bigfoot
#include <SPI.h>
#include <SdFat.h>
#include <SdFatUtil.h> 
#include <SFEMP3Shield.h>
 
SdFat sd;
SFEMP3Shield MP3player;
 
void setup() 
{
  Serial.begin(9600);
  Serial.println("setup");
 
  //start the shield
  sd.begin(SD_SEL, SPI_HALF_SPEED);
  MP3player.begin();
 
  MP3player.playTrack(1); // play track 1 for 5 seconds
  delay(5000);
 
  MP3player.stopTrack();
  MP3player.playTrack(2); // play track 2 for 2 seconds
  delay(2000);
 
  MP3player.stopTrack();
  MP3player.playMP3("track001.mp3"); // play track by file name.
}
 
//do something else now
void loop() 
{
 
  Serial.println("Kendro!");
  delay(2000);
 
}

Links: http://www.billporter.info/2012/01/28/sparkfun-mp3-shield-arduino-library/comment-page-1/#comments
Library: MP3 Shield Library
Tracks: mp3.zip

The only thing though is that the whole library eats up 1kb of RAM already. So it is recommended to use a MEGA board (with 2560)
if used in larger applications.
Comments: 0, Rating: 0

i2c Multiplexer (PCA9540B)
created: 16 May 2013 16:21
tags:
The PCA9540B is a 1-of-2 bidirectional translating multiplexer, controlled via the I2C-bus. It basically helps you use two I2C driven components that has the same address. It splits the I2C channels to two parts so that you could address each I2C outputs individually.

Here's a very good example of its use. The 128x64 OLED Display from seeedstudio I2C driver contains only one address. Unlike different types of I2C components (i.e. sainsmart, ywrobot lcd), this OLED does not have any other address, the multiplexer comes handy if you are attempting to control both OLEDs individually.

The sketch shown below is using a GOFi2cOLED library which can be downloaded here. It is a very cool library for 128x64 OLEDs since it has the function for the changing font size.

Lesson learned: Do NOT FORGET Wire.begin(); before starting to communicate within the i2c bus. I spent about a day trying to figure out that this function was the only problem and trust me it was a PIA!

#include <Wire.h>
#include <GOFi2cOLED.h>
 
GOFi2cOLED GOFoled;
 
void setup()
{
  Wire.begin(); // never forget this!!
 
  // communicate to the i2c multiplexer (address = 0x70)
  Wire.beginTransmission(0x70);
  Wire.write(0x04); // select channel 0
  Wire.endTransmission();    
 
  // initialise OLED (connected to channel 0)
  GOFoled.init(0x3C);
  GOFoled.clearDisplay();
 
  // communicate to i2c multiplexer (address = 0x70)
  Wire.beginTransmission(0x70);
  Wire.write(0x05); // select channel 1
  Wire.endTransmission();    
 
  // initialise OLED (connected to channel 1)
  GOFoled.init(0x3C);
  GOFoled.clearDisplay();
}
 
void loop()
{
  oledPrint(23, 1);  // print 23 on oled 1
  oledPrint(29, 2); // print 29 on oled 2
 
  delay(500);  
 
  oledPrint(22, 1); // print 22 on oled 1
  oledPrint(27, 2); // print 27 on oled 2
 
  delay(200);
}
 
void oledPrint(int floorNumber, int oledNumber)
{
  if(oledNumber == 1)
    oledNumber = 0x04;
  else if(oledNumber == 2)
    oledNumber = 0x05;
 
  Wire.beginTransmission(0x70);
  Wire.write(oledNumber);
  Wire.endTransmission();
 
  GOFoled.clearDisplay();
  GOFoled.setTextSize(9);
  GOFoled.setTextColor(WHITE);
  GOFoled.setCursor(15,0);
 
  GOFoled.print(String(floorNumber));
 
  GOFoled.display();
}

Output

Reference

http://www.kerrywong.com/2012/10/08/i2c-multiplexer-shield-testing/ : This guy is using a different kind of i2c Multiplexer, another family of i2c multiplexer though using similar approach.
http://www.kerrywong.com/blog/wp-content/uploads/2011/05/TempSensorSch.png : Do not forget the pull-up resistors from the Arduino Board to the multiplexer input. The OLEDs do not need any pull-ups since its soldered onboard.
Comments: 0, Rating: 0

Heads Up On Capacitive Sensors
created: 29 Apr 2013 08:48
tags:
There's an introduction on creating a simple capacitive sensor in the Arduino Playground Forum. It appears to be a straightforward example of building a capacitive sensor, and it is, but unnecessary headaches were experienced because of a basic piece of information not taken into consideration.
When building future projects with capacitive sensors we will want instantaneous results whenever we touch the sensor. Though properly hooked up, the one sensor attached was making a reading only once every 2-3 seconds, as opposed to constantly inputting new data at a rapid pace. Different resistor values, manipulation of the code, attachment of a second sensor, numerous different pieces of hardware, and shouting at the device did not solve the problem.
The code called for three separate sensors to be used, but only one was hooked up to test with, with plans to add the rest once positive results were observed. Therein lay the problem though. Capacitive sensors measure the change in capacitance from an external influence (such as one's finger). The delay in measurements displayed was due to the fact that the code was trying to measure capacitive changes from three sensors, while only one was attached. The delay was the program searching for a capacitive change, which it could not find.
The video below shows what happens when one of the three sensors is unplugged from a properly working device. It is clear that the program does not display new values quickly when a sensor is removed, since the program is searching in vain to find a change in capacitance:

With all three sensors properly hooked up, we can now have instant gratification while using capacitive sensors:


Comments: 1, Rating: 0

page 1 of 3123next »