|
楼主 |
发表于 2022-3-1 17:10
|
显示全部楼层
- void loop(){
-
- // Check for input
- if (Serial.available() > 0) {
- bufferInt = Serial.read();
- if (bufferInt == '1') {
- for(int i=0; i<nbstep; i++){
- digitalWrite(9, LOW); //ENABLE CH A
- digitalWrite(8, HIGH); //DISABLE CH B
- digitalWrite(12, HIGH); //Sets direction of CH A
- analogWrite(3, 255); //Moves CH A
- delay(delaylegnth);
-
- digitalWrite(9, HIGH); //DISABLE CH A
- digitalWrite(8, LOW); //ENABLE CH B
- digitalWrite(13, LOW); //Sets direction of CH B
- analogWrite(11, 255); //Moves CH B
- delay(delaylegnth);
-
- digitalWrite(9, LOW); //ENABLE CH A
- digitalWrite(8, HIGH); //DISABLE CH B
- digitalWrite(12, LOW); //Sets direction of CH A
- analogWrite(3, 255); //Moves CH A
- delay(delaylegnth);
-
- digitalWrite(9, HIGH); //DISABLE CH A
- digitalWrite(8, LOW); //ENABLE CH B
- digitalWrite(13, HIGH); //Sets direction of CH B
- analogWrite(11, 255); //Moves CH B
- delay(delaylegnth);
- Serial.println("i");
-
- value=digitalRead(4);
- if (value==0) {
- digitalWrite(9, HIGH); //DISABLE CH A
- analogWrite(3, 0); //stop Move CH A
- digitalWrite(8, HIGH); //DISABLE CH B
- analogWrite(11, 0); //stop Move CH B
- break;
- }
- }
- }
- }
- }
复制代码 |
|