Hi There
I'm trying to breathe life into my two wheel robot made out of a tissue box, a 3.5 Teensy a USB-speaker and 2 stepper motors and several sensors..
See here:
Each module like the audio and stepper-Motor are running fine in individual Sketches, x.ino's. But together they dont, any idea? ::
I'm trying to breathe life into my two wheel robot made out of a tissue box, a 3.5 Teensy a USB-speaker and 2 stepper motors and several sensors..
See here:
Each module like the audio and stepper-Motor are running fine in individual Sketches, x.ino's. But together they dont, any idea? ::
Code:
// MultiStepper.pde
// -*- mode: C++ -*-
//
// Shows how to multiple simultaneous steppers
// Runs one stepper forwards and backwards, accelerating and decelerating
// at the limits. Runs other steppers at the same time
//
// Copyright (C) 2009 Mike McCauley
// $Id: MultiStepper.pde,v 1.1 2011/01/05 01:51:01 mikem Exp mikem $
#include <AccelStepper.h>
// Define some steppers and the pins the will use
AccelStepper stepper1(AccelStepper::FULL4WIRE, 0, 1, 2, 3);; // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5
AccelStepper stepper2(AccelStepper::FULL4WIRE, 25,26, 27, 28);
// AUDIO
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
//https://online-audio-converter.com/de/
// WIn 10 Sprach recorder
AudioPlaySdWav playWav1;
AudioOutputAnalog audioOutput;
AudioConnection patchCord1(playWav1, 0, audioOutput, 0);
AudioConnection patchCord2(playWav1, 1, audioOutput, 1);
AudioControlSGTL5000 sgtl5000_1;
#define SDCARD_CS_PIN BUILTIN_SDCARD
#define SDCARD_MOSI_PIN 11 // not actually used
#define SDCARD_SCK_PIN 13 // not actually used
void setup()
{
stepper1.setMaxSpeed(400.0);
stepper1.setAcceleration(100.0);
stepper1.moveTo(200);
stepper2.setMaxSpeed(-400.0);
stepper2.setAcceleration(100.0);
stepper2.moveTo(-200);
// AUDIO
Serial.println("Start AUDIO...");
AudioMemory(8);
SPI.setMOSI(SDCARD_MOSI_PIN);
SPI.setSCK(SDCARD_SCK_PIN);
if (!(SD.begin(SDCARD_CS_PIN))) {
while (1) {
Serial.println("Unable to access the SD card");
delay(500);
}
}
// END AUDIO
playFile("SILENTN.WAV");
}
void playFile(const char *filename)
{
Serial.print("Playing file: ");
Serial.println(filename);
playWav1.play(filename);
delay(5);
//while (playWav1.isPlaying()) {
//}
}
void loop()
{
stepper1.run();
stepper2.run();
}
Last edited: