hello,
i'm new coding arduino, , have been running odd problem project i'm building. 1 button push, trying to:
after few seconds should stop , return normal (white lights on, else off).
the shield appears functioning correctly , song plays , stops needed. red light , continuous rotation servo behave expected. trouble lies regular servo , white lights.
when button pushed, regular servo tries rotate beyond limit, , each time board reset, rotates appears 30 degrees. when mp3 shield not in loop, behaved expected (started @ 30-degree mark , rotated 90, etc).
the white lights begin flicker instead of turn off when button pushed. when mp3 shield isn't involved, turn off expected.
other deets:
any can send way appreciated. i'm working on deadline, , can't seem fish out what's happening here.
here's code i'm working far:
i'm new coding arduino, , have been running odd problem project i'm building. 1 button push, trying to:
- turn off 1 set of lights (white)
- turn on 1 set of lights (red)
- turn on continuous rotation servo
- turn on traditional servo (starting @ 30-degrees , rotating 90-degrees , back)
- start play mp3 via adafruit mp3 shield
after few seconds should stop , return normal (white lights on, else off).
the shield appears functioning correctly , song plays , stops needed. red light , continuous rotation servo behave expected. trouble lies regular servo , white lights.
when button pushed, regular servo tries rotate beyond limit, , each time board reset, rotates appears 30 degrees. when mp3 shield not in loop, behaved expected (started @ 30-degree mark , rotated 90, etc).
the white lights begin flicker instead of turn off when button pushed. when mp3 shield isn't involved, turn off expected.
other deets:
- the lights connected via relay , have own external power supply. arduino turning relay switches on , off. white lights wired when no power supplied arduino relay, lights on. red set opposite.
- servo issues hitec hs-322hd deluxe
any can send way appreciated. i'm working on deadline, , can't seem fish out what's happening here.
here's code i'm working far:
code: [select]
//libraries include
#include <spi.h>
#include <adafruit_vs1053.h>
#include <sd.h>
#include <servo.h>
//assign servos
servo continuousservo;
servo regservo;
#define breakout_reset 9 // vs1053 reset pin (output)
#define breakout_cs 10 // vs1053 chip select pin (output)
#define breakout_dcs 8 // vs1053 data/command select pin (output)
#define shield_reset -1
#define shield_cs 7 // vs1053 chip select pin (output)
#define shield_dcs 6 // vs1053 data/command select pin (output)
#define cardcs 4 // card chip select pin
#define dreq 3 // vs1053 data request, ideally interrupt pin
adafruit_vs1053_fileplayer musicplayer =
adafruit_vs1053_fileplayer(shield_cs, shield_dcs, dreq, cardcs);
const int whitelightpin = 12;
const int redlightpin = 5;
int buttonvalue = 0;
void setup() {
(! musicplayer.begin());
sd.begin(cardcs);
musicplayer.setvolume(8,8);
musicplayer.useinterrupt(vs1053_fileplayer_pin_int);
//set button
pinmode(a0, input);
//set lights
pinmode(redlightpin, output); // set pin connected red lights output
pinmode(whitelightpin, output);
digitalwrite(redlightpin, high); // set pin turn red lights off
digitalwrite(whitelightpin, high);
//set servos
continuousservo.attach(13);
regservo.attach(11);
regservo.write(30);
continuousservo.write(94);
}
void loop() {
buttonvalue = digitalread(a0);
if (buttonvalue == high) {
musicplayer.startplayingfile("1.mp3");
delay(6050);
digitalwrite(redlightpin, low);
digitalwrite(whitelightpin, low);
continuousservo.write(91);
regservo.write(90);
delay(10000);
musicplayer.stopplaying();
buttonvalue = 1 - buttonvalue;
digitalwrite(redlightpin, high);
digitalwrite(whitelightpin, high);
continuousservo.write(94);
regservo.write(30);
}
}
hi , welcome.
post schematic please. hand drawn ok long neat enough read. details of power supply circuit. powering these leds , 2 servos 5v output of arduino example?
paul
post schematic please. hand drawn ok long neat enough read. details of power supply circuit. powering these leds , 2 servos 5v output of arduino example?
paul
Arduino Forum > Using Arduino > LEDs and Multiplexing > LED +Servo misbehaving w/ Adafruit MP3 shield attached
arduino
Comments
Post a Comment