Created
October 7, 2014 00:33
-
-
Save ringodin/fbde2e2d43a1c91b7190 to your computer and use it in GitHub Desktop.
This will be for students learning about for loops
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int pwm_a = 3; //PWM control for motor outputs 1 and 2 is on digital pin 3 | |
int pwm_b = 11; //PWM control for motor outputs 3 and 4 is on digital pin 11 | |
int dir_a = 12; //direction control for motor outputs 1 and 2 is on digital pin 12 | |
int dir_b = 13; //direction control for motor outputs 3 and 4 is on digital pin 13 | |
int val = 0; //value for fade | |
void setup() | |
{ | |
pinMode(pwm_a, OUTPUT); //Set control pins to be outputs | |
pinMode(pwm_b, OUTPUT); | |
pinMode(dir_a, OUTPUT); | |
pinMode(dir_b, OUTPUT); | |
analogWrite(pwm_a, 100); //set both motors to run at (100/255 = 39)% duty cycle (slow) | |
analogWrite(pwm_b, 100); | |
} | |
void loop() | |
{ | |
delay(1000); | |
for (int i=0; i < 4; i++) | |
{ | |
forward(); | |
delay(2000); | |
stopped(); | |
delay(500); | |
left(); | |
delay(800); | |
stopped(); | |
delay(500); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment