Привет всем. Помогите плиз новичку.
Вообщем, вот код. Пока просто цыкл для полевиков-движков.
=====
PHP код:
int sensorPin = 3; //pin for pwr-sensor
const int startPin=0; //button
int buttonState = 0; // variable for reading the pushbutton status
int MotorPin1 = 8;//pin for pwr-motor1
int MotorPin2 = 9;//pin for pwr-motor2
int MotorPin3 = 10;//pin for pwr-motor3
int MotorPin4 = 11;//pin for pwr-motor4
void setup() {
// nothing happens in setup
// initialize the motor pin as an output:
pinMode(MotorPin1, OUTPUT);
pinMode(MotorPin2, OUTPUT);
pinMode(MotorPin3, OUTPUT);
pinMode(MotorPin4, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(startPin, INPUT);
// read the state of the pushbutton value:
}
void loop() {
buttonState=LOW;
buttonState = digitalRead(startPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState = HIGH) {
// turn Motor_all on:
digitalWrite(MotorPin1, HIGH);
delay(500);
digitalWrite(MotorPin1, LOW);
digitalWrite(MotorPin2, HIGH);
delay(500);
digitalWrite(MotorPin2, LOW);
digitalWrite(MotorPin3, HIGH);
delay(500);
digitalWrite(MotorPin3, LOW);
digitalWrite(MotorPin4, HIGH);
delay(500);
digitalWrite(MotorPin4, LOW);
buttonState=LOW;
}
else {
digitalWrite(MotorPin1, LOW);
digitalWrite(MotorPin2, LOW);
digitalWrite(MotorPin3, LOW);
digitalWrite(MotorPin4, LOW);
}
buttonState = digitalRead(startPin);
buttonState=LOW;
}
=======
В протеусе симулирую, т.е. жмем кнопарь (startPin), моторы зашуровали.
Вроде я состояние нажатия (buttonState), делаю LOW, в конце цыкла. Но моторы продолжают шуровать дальше.
Подскажите где я затупил)