Arduino inside a Mario Costume

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Arduino inside a Mario Costume

Postby djmacatack » Mon Oct 05, 2009 12:36 am

Hey guys,

I just put together a costume project using a Wave shield. I don't need help with anything but since I bought everything from Adafruit I thought I'd share. Note that I'm new here so I don't know the forum etiquette.

http://www.youtube.com/watch?v=zj-I0zMkIQk

The code is not very clean because it was recycled from a previous failed project that used more LED's. I used some creative looping to save text space.

Code: Select all
#include <AF_Wave.h>
#include <avr/pgmspace.h>
#include "util.h"
#include "wave.h"

#define DEBOUNCE 20

#define swPin 14
int value = 255;   
int ledpin[] = {18,19,6,7,8}; //5 output pins declared 1 used
AF_Wave card;
File f;
Wavefile wave;

void setup() {
  byte i;
  digitalWrite(ledpin[1], LOW);//Default off
  Serial.begin(9600);
  for (byte i = 2; i <= 5; ++i) {
    pinMode(i, OUTPUT);
  }
  for (byte i = 1; i <= 5; ++i) {
    pinMode(ledpin[i], OUTPUT);
  }
  for (byte i = swPin + 1; i <= swPin + 3; ++i) {
    digitalWrite(i, HIGH);
  }

  if (!card.init_card()) {
    putstring_nl("Card init failed!"); return;
  }
  if (!card.open_partition()) {
    putstring_nl("No partition!"); return;
  }
  if (!card.open_filesys()) {
    putstring_nl("Couldn't open filesys"); return;
  }
  if (!card.open_rootdir()) {
    putstring_nl("Couldn't open dir"); return;
  }
}

void loop() {   
  switch (check_switches()) {
    case 2:
    {
      playfile(picker(0,1));
      while (wave.isplaying)
      {
        shot();
      }
      break;
    }
    case 3:
    {
      playfile(picker(1,8));
       while (wave.isplaying)
      {

      }
      break;
    }
    case 4:
      playfile(picker(8,11));
  }
}

void shot()
{

      digitalWrite(ledpin[1], HIGH);   
      delay(200);                 
      digitalWrite(ledpin[1], LOW); 
      delay(100);

}
byte check_switches()
{
  static byte previous[6];
  static long time[6];
  byte reading;
  byte pressed;
  byte index;

  for (index = 0; index < 6; ++index) {
    reading = digitalRead(swPin + index);
    if (reading == LOW && previous[index] == HIGH && millis() - time[index] > DEBOUNCE)
    {
      time[index] = millis();
      pressed = index + 1;
      break;
    }
    previous[index] = reading;
  }
  return (pressed);
}
char* picker(int low, int high)
{
  char* str[]={"FIREBALL.WAV", "JUMP1.WAV", "JUMP2.WAV", "JUMP3.WAV", "JUMP4.WAV", "JUMP5.WAV", "JUMP6.WAV", "JUMP6.WAV", "SONG1.WAV", "SONG2.WAV", "SONG3.WAV"};
  int i = random(low, high);
  return str[i];
}
void playfile(char *name) {
  if (wave.isplaying) {
    wave.stop();
  }
  if (f) {
    card.close_file(f);
  }
  f = card.open_file(name);
  if (f && wave.create(f)) {
    wave.play();
  }
}
djmacatack
 
Posts: 4
Joined: Mon Oct 05, 2009 12:22 am

Re: Arduino inside a Mario Costume

Postby adafruit » Mon Oct 05, 2009 11:59 am

damn that is WAY COOL!!!
User avatar
adafruit
 
Posts: 10483
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: Arduino inside a Mario Costume

Postby djmacatack » Fri Oct 30, 2009 5:40 pm

Hey and thanks for the blog mention awhile back. I wanted to post a vid of the finished product. Enjoy.

http://www.youtube.com/watch?v=oiWxle-KvHg
djmacatack
 
Posts: 4
Joined: Mon Oct 05, 2009 12:22 am



Return to Arduino

Who is online

Users browsing this forum: mibignistinly and 9 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [105]

Raspberry Pi[80]
 
FLORA[23]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[11]
Arduino[60]
 
NETduino[14]
 
BeagleBone[24]
 
Android[6]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[33]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[8]


 
Breakout Boards[33]
LCDs & Displays[48]
Components & Parts[69]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[108]
 
Wireless[14]
Cables[60]
 
Lasers[6]
Sensors/Parts[145]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[69]
 
iDevices[13]
Tools[71]
 
Wearables[39]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[24]


 
Stickers[41]
 
Skill badges[55]
 
Books[25]
 
Circuit Playground[7]
 
Gift Certificates[4]