Salve a tutti, da diversi giorni sto riscontrando un problema CON ARDUINO DUE e le matrici led di Adafruit e un servomotore classico. Non appena collego il servo a qualsiasi pin sia pwm che digitale non mi funziona. se mi invece commento ''matrix.show()'' allora il servo funziona perfettamente. pensavo fosse un problema di conflitto tra librerie. qualcuno mi può aiutare?grazie mille in anticipo
ecco il codice:
#include <Servo.h>
#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#ifndef PSTR
#define PSTR // Make Arduino Due happy
#endif
#define PIN 6
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(32, 8, 3, 1, PIN,
NEO_TILE_TOP + NEO_TILE_RIGHT + NEO_TILE_COLUMNS + NEO_TILE_PROGRESSIVE +
NEO_MATRIX_TOP + NEO_MATRIX_RIGHT + NEO_MATRIX_COLUMNS + NEO_MATRIX_PROGRESSIVE
,
NEO_GRB + NEO_KHZ800);
const uint16_t colors[] = {
matrix.Color(255, 0, 0), matrix.Color(0, 255, 0), matrix.Color(0, 0, 255)
};
uint16_t color = colors[0];
Servo myservo;
int pos = 0;
int x = 0;
int y = 0;
int pass0,pass1,pass2,pass3,pass4,pass5 = 0;
int j=0;
boolean stringComplete = false; // whether the string is complete
int inputCommand;
void setup() {
pinMode( 52,OUTPUT);
myservo.attach(9);
matrix.begin();
matrix.setTextWrap(false);
matrix.setBrightness(10);
matrix.setTextColor(colors[0]);
// initialize serial:
Serial.begin(9600);
// reserve 200 bytes for the inputString:
//inputString.reserve(200);
}
void loop() {
serialEvent(); //call the function
digitalWrite(52,LOW);
matrix.fillScreen(0);
matrix.drawLine(pass0, 0, pass0, 7, colors[0]);
matrix.drawLine(pass1, 0, pass1, 7, colors[0]);
matrix.drawLine(pass2, 0, pass2, 7, colors[0]);
matrix.drawLine(pass3, 0, pass3, 7, colors[1]);
matrix.drawLine(pass4, 0, pass4, 7, colors[1]);
matrix.drawLine(pass5, 0, pass5, 7, colors[1]);
matrix.show();
delay(100);
}
void serialEvent() {
inputCommand = Serial.read();
switch(inputCommand){
case 'r':
color = colors[0];
break;
case 'g':
color = colors[1];
break;
case 'b':
color = colors[2];
break;
case 't'://turn the servomotor
for(pos = 0; pos < 180; pos += 1)
{
myservo.write(pos);
delay(15);
}
for(pos = 180; pos>=1; pos-=1)
{
myservo.write(pos);
delay(15);
}
break;
case 'a':
digitalWrite( 52,HIGH);
delay(80);
pass0=82;
pass1=83;
pass2=84;
pass3=62;
pass4=63;
pass5=64;
//digitalWrite(52,LOW);
break;
case 'c':
digitalWrite( 52,HIGH);
delay(80);
//digitalWrite(52,LOW);
pass0=12;
pass1=13;
pass2=14;
pass3=37;
pass4=38;
pass5=39;
break;
}
inputCommand = 0;
}