diff --git a/Learn/Examples/Robots/ActivityBot360/IR Follow the Leader.c b/Learn/Examples/Robots/ActivityBot360/IR Follow the Leader.c new file mode 100644 index 00000000..b5577126 --- /dev/null +++ b/Learn/Examples/Robots/ActivityBot360/IR Follow the Leader.c @@ -0,0 +1,49 @@ +/* + IR Follow the Leader.c + + Follow another ActivityBot 360, your hand and other targets. + + http://learn.parallax.com/activitybot/ir-follow-the-leader +*/ + +#include "simpletools.h" // Include simpletools +#include "abdrive360.h" + +int irLeft, irRight; // Global variables +int errorLeft, errorRight; +int driveLeft, driveRight; +int setPoint = 4; +int kp = -12; + +int main() // Main function +{ + pwm_start(255); + + low(26); // D/A0 & D/A1 to 0 V + low(27); + + while(1) // Main loop + { + irLeft = 0; // Detect variables to 0 + irRight = 0; + + for(int da = 189; da >= 0; da -= 27) // Sweep da pins + { + pwm_set(26, 0, da); + pwm_set(27, 1, da); + freqout(11, 1, 38000); // Left IR LED light + irLeft += input(10); // Check left IR detector + freqout(1, 1, 38000); // Repeat for right detector + irRight += input(2); + } + + errorLeft = setPoint - irLeft; + errorRight = setPoint - irRight; + + driveLeft = kp * errorLeft; + driveRight = kp * errorRight; + + drive_speed(driveLeft, driveRight); + } +} + diff --git a/Learn/Examples/Robots/ActivityBot360/IR Follow the Leader.side b/Learn/Examples/Robots/ActivityBot360/IR Follow the Leader.side new file mode 100644 index 00000000..5c4826ef --- /dev/null +++ b/Learn/Examples/Robots/ActivityBot360/IR Follow the Leader.side @@ -0,0 +1,9 @@ +IR Follow the Leader.c +>compiler=C +>memtype=cmm main ram compact +>optimize=-Os +>-m32bit-doubles +>-fno-exceptions +>defs::-std=c99 +>-lm +>BOARD::ACTIVITYBOARD diff --git a/Learn/Examples/Robots/ActivityBot360/Test IR Distances.c b/Learn/Examples/Robots/ActivityBot360/Test IR Distances.c new file mode 100644 index 00000000..c6b5403e --- /dev/null +++ b/Learn/Examples/Robots/ActivityBot360/Test IR Distances.c @@ -0,0 +1,41 @@ +/* + IR Test Distances.c + + Test distance detection with infrared detectors. + + http://learn.parallax.com/activitybot/ir-test-distances +*/ + +#include "simpletools.h" // Include simpletools +#include "abdrive360.h" + +int irLeft, irRight; // Global variables + +int main() // Main function +{ + pwm_start(255); + + low(26); // D/A0 & D/A1 to 0 V + low(27); + + while(1) // Main loop + { + irLeft = 0; // Detect variables to 0 + irRight = 0; + + for(int da = 189; da >= 0; da -= 27) // Sweep da pins + { + pwm_set(26, 0, da); + pwm_set(27, 1, da); + freqout(11, 1, 38000); // Left IR LED light + irLeft += input(10); // Check left IR detector + freqout(1, 1, 38000); // Repeat for right detector + irRight += input(2); + } + + print("%c irLeft = %d, irRight = %d ", // Display detector states + HOME, irLeft, irRight); + pause(100); // Pause before repeating + } +} + diff --git a/Learn/Examples/Robots/ActivityBot360/Test IR Distances.side b/Learn/Examples/Robots/ActivityBot360/Test IR Distances.side new file mode 100644 index 00000000..b5712894 --- /dev/null +++ b/Learn/Examples/Robots/ActivityBot360/Test IR Distances.side @@ -0,0 +1,9 @@ +Test IR Distances.c +>compiler=C +>memtype=cmm main ram compact +>optimize=-Os +>-m32bit-doubles +>-fno-exceptions +>defs::-std=c99 +>-lm +>BOARD::ACTIVITYBOARD diff --git a/version.txt b/version.txt index 57279742..afc34b3c 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -v1.4.118 +v1.4.119