terribleidea
New member
are there any issues with regards to controlling a servo, even with an audio shield attached?..
I was trying the code found here : https://www.pjrc.com/teensy/td_libs_Servo.html
and the servo doesnt seem to move or anything..
I am planning to use the servo together with the audio shield attached. since i want to control the servo based on the specific FFT bin/point amplitude..
servo teeensy
GND - ------- - GND
SIGNAL/ DATA - -- pin 29
VCC - ------------ -5v external power..
currently having this code for the mean time to test the servo only ...
I was trying the code found here : https://www.pjrc.com/teensy/td_libs_Servo.html
and the servo doesnt seem to move or anything..
I am planning to use the servo together with the audio shield attached. since i want to control the servo based on the specific FFT bin/point amplitude..
servo teeensy
GND - ------- - GND
SIGNAL/ DATA - -- pin 29
VCC - ------------ -5v external power..
currently having this code for the mean time to test the servo only ...
Code:
//----------------------
#include <Servo.h>
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
#include <Servo.h>
Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created
int pos = 0; // variable to store the servo position
// GUItool: begin automatically generated code
AudioInputI2S i2s1; //xy=567,347
AudioAnalyzeFFT256 fft256_1; //xy=777,355
AudioConnection patchCord1(i2s1, 0, fft256_1, 0);
AudioControlSGTL5000 sgtl5000_1; //xy=689,499
// GUItool: end automatically generated code
void setup() {
myservo.attach(29);
Serial.begin(9600);
delay(1000);
Serial.println("FFT RESULTS");
//fft1024_1.windowFunction(AudioWindowHanning1024);
AudioMemory(12);
}
int delayValue = 50;
void loop() {
float n;
int i;
for(pos = 10; pos < 170; pos += 1) // goes from 10 degrees to 170 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
/*
if (fft256_1.available()) {
Serial.print("FFT: ");
for (i=0; i<75; i++) {
n = fft256_1.read(i);
if (n >= 0.01) {
Serial.print(n);
Serial.print(" ");
} else {
Serial.print(" - "); // don't print "0.00"
}
}
Serial.println();
}
delay(delayValue); // Delay for a period of time (in milliseconds).
*/
}
//---------------------