
158 Make: Robotic Arms
int lastStateCLK;
int posOne = 90;
int posTwo = 90;
int posThree = 90;
int posFour = 180;
int posFive = 90;
int motorSelector = 1;
void setup() {
servoOne.attach(3);
servoTwo.attach(5);
servoThree.attach(6);
servoFour.attach(9);
servoFive.attach(10);
pinMode(CLK, INPUT);
pinMode(DT, INPUT);
pinMode(SW, INPUT_PULLUP);
lastStateCLK = digitalRead(CLK);
Serial.begin(9600);
}
void loop() {
currentStateCLK = digitalRead(CLK);
if (currentStateCLK != lastStateCLK) {
if (digitalRead(DT) == currentStateCLK) {
if(motorSelector == 1){
posOne-=5;
}
else if(motorSelector == 2){
posTwo-=5;
posThree+=5;
}
else if(motorSelector == 3){
posFour-= ...