oh sorry here it is everything works independently but when trying to send commands it seems as if I'm bombarded with random data idk if it's my app of iff my code is producing weird values or taking wired values
#include <Adafruit_SoftServo.h>
#include <SoftwareSerial.h>
#define SERVO1PIN 3
#define SERVO2PIN 4
#define TXPIN 0 //Connected to TX on HM-10
#define RXPIN 1 //Connected to RX on HM-10
int moveAmount = 1; // change this value to change speed of servo
SoftwareSerial Serial(0,1); //RX|TX
Adafruit_SoftServo myServo1, myServo2;
void setup() {
Serial.begin(9600);
while (!Serial);
// Set up the interrupt that will refresh the servo for us automagically
OCR0A = 0xAF; // any number is OK
TIMSK |= _BV(OCIE0A); // Turn on the compare interrupt (below!)
myServo1.attach(SERVO1PIN);
myServo2.attach(SERVO2PIN); // Attach the servo to pin 0 on Trinket
myServo1.write(12);
myServo2.write(12);
}
void loop()
{
if (Serial.available() > 0)
{
char w = Serial.read();
int pos = 90;
int pos2 = 0;
if (w == 'a')
{ //add brace
for (pos = 90; pos <= 102; pos += 1)
{
myServo2.write(pos);
delay(2000);
}
for (pos2 = 0; pos2 <= 180; pos2 += 1)
{
myServo1.write(pos2);
pos2 = pos2 + moveAmount;
if (pos2 == 0 || pos2 == 180) {
moveAmount = -moveAmount;
}
}
delay(15);
}//add brace
if (w == 'z')
{ //add brace
for (pos = 0; pos >= 90; pos -= 1)
{
myServo2.write(90);
delay(20);
}
}//add brace
}
}
// We'll take advantage of the built in millis() timer that goes off
// to keep track of time, and refresh the servo every 20 milliseconds
// The SIGNAL(TIMER0_COMPA_vect) function is the interrupt that will be
// Called by the microcontroller every 2 milliseconds
volatile uint8_t counter = 0;
SIGNAL(TIMER0_COMPA_vect) {
// this gets called every 2 milliseconds
counter += 2;
// every 20 milliseconds, refresh the servos!
if (counter >= 20) {
counter = 0;
myServo1.refresh();
myServo2.refresh();//add this line for second servo
}
}