Ping Pong Larson Scanner (3 / 3 steg)
Steg 3: programvara
Portugisiska:
Para inserir o programvara, primeiro clique ingen Arduino. EM baixo protoboard irá aparecer o redaktör de código. Clique nele e aparecerá en tela para inserir o programvara.
Programvara:
#include < Servo.h >
Servo myservoR;
Servo myservoL;
int val;
int pinArray [] = {12, 11, 10, 9, 8, 7, 6, 5};
int count = 0;
int timer = 25;
void setup() {
myservoR.attach(3);
myservoL.attach(13);
för (count = 0; räkna < 8; räkna ++) {
pinMode (pinArray [antal], produktionen);
}
}
void loop() {
för (count = 0; räkna < 8; räkna ++) {
digitalWrite (pinArray [antal], hög);
Delay(timer);
digitalWrite (pinArray [count + 1], hög);
val = (antal * 22,5);
myservoR.write(val);
myservoL.write(val);
Delay(timer);
digitalWrite (pinArray [antal], låg);
Delay(timer*2);
}
för (count = 7; count > 0; count--) {
digitalWrite (pinArray [antal], hög);
digitalWrite (pinArray [antal], hög);
Delay(timer);
digitalWrite (pinArray [count - 1], hög);
val=(Count*22.5);
myservoR.write(val);
myservoL.write(val);
Delay(timer);
digitalWrite (pinArray [antal], låg);
Delay(timer*2);
}
}