int motor1pin1 = 2; int motor1pin2 = 3; int motor2pin1 = 4; int motor2pin2 = 5; void setup() { // put your setup code here, to run once: pinMode(motor1pin1,OUTPUT); pinMode(motor1pin2,OUTPUT); pinMode(motor2pin1,OUTPUT); pinMode(motor2pin2,OUTPUT); } void forward() { digitalWrite(motor1pin1,HIGH); digitalWrite(motor1pin2,LOW); digitalWrite(motor2pin1,LOW); digitalWrite(motor2pin2,HIGH); delay(1000); } void pause() { digitalWrite(motor1pin1,LOW); digitalWrite(motor1pin2,LOW); digitalWrite(motor2pin1,LOW); digitalWrite(motor2pin2,LOW); delay(1000); } void loop() { // put your main code here, to run repeatedly: forward(); pause(); }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter