Hi,
real arduino beginner here, someone else compiled this code for me for a button activated circuit that turns on leds, has a colour change at time intervals and activates sound effects running on an Adafruit Waveshield. I can’t get hold of the original code writer and when I verify it through the IDE I receive the following errors:
In file included from /Users/dangudgeon/Documents/Arduino/sketch_jun12b/sketch_jun12b.ino:4:0:
/Users/dangudgeon/Documents/Arduino/libraries/AF_Wave/util.h:3:0: warning: "UINT16_MAX" redefined
#define UINT16_MAX 65535U
^
In file included from /Applications/Arduino.app/Contents/Java/hardware/tools/avr/lib/gcc/avr/5.4.0/include/stdint.h:9:0,
from /Applications/Arduino.app/Contents/Java/hardware/tools/avr/avr/include/inttypes.h:37,
from /Applications/Arduino.app/Contents/Java/hardware/tools/avr/avr/include/avr/pgmspace.h:88,
from /Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino/Arduino.h:28,
from sketch/sketch_jun12b.ino.cpp:1:
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/avr/include/stdint.h:346:0: note: this is the location of the previous definition
#define UINT16_MAX (__CONCAT(INT16_MAX, U) * 2U + 1U)
^
/Users/dangudgeon/Documents/Arduino/sketch_jun12b/sketch_jun12b.ino: In function 'void loop()':
/Users/dangudgeon/Documents/Arduino/sketch_jun12b/sketch_jun12b.ino:34:19: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
playfile(SOUND);
^
This is my code:
#include <Adafruit_NeoPixel.h>
#include <AF_Wave.h>
#include <avr/pgmspace.h>
#include "util.h"
#include "wave.h"
#define TIME 60000 //60000 milli second = 60 seconds = 1 min
#define SOUND "Lakeside.WAV" //Audio file name
#define Button 7
#define Led 8
#define LED_PIN 6
#define LED_COUNT 150
AF_Wave card;
File f;
Wavefile wave;
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
int start = 0;
int wasplaying = 0;
int i = 0;
int waitTime = TIME / 256;
void setup() {
hardwareinit();
}
void loop() {
if (digitalRead(Button) == LOW && start == 0) {
start = 1;
digitalWrite(Led , HIGH);
playfile(SOUND);
i = 0;
}
if (start == 1) {
for ( ; i < 256 ; i++)
{
Serial.println(i);
colorWipe(strip.Color(i, 255 - i, 255 - i), 50);
if (digitalRead(Button) == HIGH)
digitalWrite(Led , LOW);
delay(waitTime);
}
start = 0;
}
}
void hardwareinit() {
Serial.begin(9600);
strip.begin();
strip.show();
strip.setBrightness(90);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(Button , INPUT_PULLUP);
pinMode(Led , OUTPUT);
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;
}
ls();
}
void colorWipe(uint32_t color, int wait) {
for (int i = 0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, color);
}
strip.show();
}
void ls() {
char name[13];
card.reset_dir();
putstring_nl("Files found:");
while (1) {
if (!card.get_next_name_in_dir(name)) {
card.reset_dir();
return;
}
Serial.println(name);
}
}
void playfile(char *name) {
f = card.open_file(name);
if (!f) {
putstring_nl("Couldn't open file"); return;
}
if (!wave.create(f)) {
putstring_nl("Not a valid WAV"); return;
}
wave.play();
}
Trying to search the internet for answers but not having much luck.
My code knowledge is very basic and I really appreciate people’s patience