So i came across this Death Star Christmas Tree Topper i would like to do but im having a little trouble getting it coded and wired up. Im hopping someone might be able to help me finish it off or at least get me past this point.
So this is the instructables link
Basically i’m not sure what pins connect to what on the Arduino Uno board. for the Switches, Laser, Motion Sensor. So i made some adjustments to what i think will work but i can’t seem to get the code to upload to check it. Its telling me it there’s no such #include <FatReader.h> file
Any help with this would be great. I have attached everything im using plus old and adjusted stuff.
This is his layout. I had trouble figuring out what pins he used so i made some changes.
This is my updated layout im using
Here is my adjusted Code
/**
* deathStarPlayer Plays the music and sounds for the Death Star
*
* @author Kevin Craine
*/
// General stuff
const int DEBUG = 0;
// Count for delay between sounds
const unsigned int AUTO_TIME_DELAY = 8000; // Delay between sound plays when in auto play mode
const unsigned long MOTION_TIME_DELAY = 1800000; // Delay between sound plays when in motion control mode
static unsigned long timeTrack = 0; // Keeps track of overall time to see if we need to trigger an event
// Mode selecting and tracking
int modeSwitchPin = 10; // Switch that will cycle between the different modes
int modeSelected = 0; // Default is 0 = motion sensor enabled, 1 = auto play (no input), 2 = off
int modeSwitchState; // Keeps track of the state of the switch, so we only get one hit when pressed
int pinValue; // Holds the pins value
int pinValue2; // Holds the pins value again (check for bounce)
// Motion Sensor
int pirPin = 15; // Pin that will get HIGH/LOW values from motion sensor
// Stuff for Wave Shield
#include <FatReader.h>
#include <SdReader.h>
#include <avr/pgmspace.h>
#include "WaveUtil.h"
#include "WaveHC.h"
// Some variables to hold info for the Wave Shield
SdReader card;
FatVolume vol;
FatReader root;
FatReader file;
WaveHC wave;
// Sound files that we will use
const int NUM_OF_FILES = 3; //Number of WAV Files
char *wavFiles[] = {"IMPERIAL.WAV", "FIRING.WAV", "DEATHSTR.WAV"};
// Stuff for Weapon Firing
const int COUNT_GREEN_SETS = 4; // Count of the number of green sets in the circle
int greenCirclePins[COUNT_GREEN_SETS]; // Array for perimeter leds
int greenCenterPin = 11; // Green Center LED to digital pin 11
// Counts for Weapon Firing
const int TIME_TO_START_WEAPON = 9350; // Number of milliseconds before we initiate the LEDs
const int TIME_TO_WEAPON_FULL = 12560; // Number of milliseconds before full weapon firing
const int TIME_TO_WEAPON_STOP = 14210; // Number of milliseconds weapon shutdown
// Button for firing
int firingSwitchPin = 12; // Switch for overriding current function and start firing sequence
int firingSwitchState; // Keeps track of the state of the switch, so we only get one hit when pressed
/**
* setupWave Initialize Wave Shield
*/
void setupWave() {
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
if (!card.init()) {
if (DEBUG) putstring_nl("Card init failed.");
while(1);
}
card.partialBlockRead(true);
uint8_t part;
for (part = 0; part < 5; part++) {
if (vol.init(card, part)) break;
}
if (part == 5) {
if (DEBUG) putstring_nl("No valid FAT partition.");
while(1);
}
if (!root.openRoot(vol)) {
if (DEBUG) putstring_nl("Unable to open root directory.");
while(1);
}
}
/**
* setupWeapon Initialize Weapon
*/
void setupWeapon() {
greenCirclePins[0] = 6; // Green Set 1 LEDs to digital pin 6
greenCirclePins[1] = 7; // Green Set 1 LEDs to digital pin 7
greenCirclePins[2] = 8; // Green Set 1 LEDs to digital pin 8
greenCirclePins[3] = 9; // Green Set 1 LEDs to digital pin 9
// initialize the digital pin as an output:
for(int x = 0; x < COUNT_GREEN_SETS; x++) {
pinMode(greenCirclePins[x], OUTPUT);
}
pinMode(greenCenterPin, OUTPUT);
pinMode(firingSwitchPin, INPUT);
}
/**
* checkMode Checks to see if we are switching modes
*/
void checkMode() {
pinValue = digitalRead(modeSwitchPin);
delay(10); // Bounce check
pinValue2 = digitalRead(modeSwitchPin);
if (pinValue == pinValue2 && pinValue != modeSwitchState && pinValue) {
modeSelected = (modeSelected + 1) % 3;
if (DEBUG) {
putstring("Mode Selected: ");
Serial.print(modeSelected);
putstring_nl(".");
}
// This will visualize the mode selected for user.
for (int x = 0; x <= modeSelected; x++) {
weaponToggle(HIGH);
delay(300);
weaponToggle(LOW);
delay(200);
}
}
modeSwitchState = pinValue;
}
I attached the full original code my full adjusted code and the .h files im using.
Original_Code.ino (7.87 KB)
FatReader.h.h (7.76 KB)
SdReader.h.h (5.19 KB)
WaveHC.h.h (3.32 KB)
WaveUtil.h.h (527 Bytes)
DeathStar_Arduino.ino (7.87 KB)