I am trying to program a jr servo motor to work with a myoware muscle sensor and I just can't get my code to work. Can you guys please look at my code and help me? I am really stuck and I need this code to work so I can have data to present for my engineering project on Thursday.
Code is below:
#include<Servo.h>
#include <Process.h>
Servo myservo;
const int threshValue=40;
int pos = 0;
int seconds;
int lastSecond = 60;
int time = 60;
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
myservo.attach(9);
}
void loop() {
// read the input on analog pin 3:
int sensorValue = analogRead(A3);
// print out value read:
Serial.println(sensorValue);
delay(1); // delay in between reads for stability
for (pos = 0; pos <= 90; pos += 1) { // goes from 0 degrees to 90 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 postition
}
for (pos = 90; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to postition in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
int value = analogRead(9);
Serial.print("Time: ");
time = (60);
//prints time since program started
Serial.println(60, DEC);
// wait a second so as not to send massive amounts of data
delay(1000);
if(pos = 0 && pos <= 90 && pos += 1);
{
myservo.(18);
}
else(pos = 90 && pos >= 0 && pos -= 1);
{
myservo.(18);
}
}
Please help, I promise all credit goes to the one who has helped me getting the code to work. I am really bad at programming and still in the process of learning.