Skip to content

Instantly share code, notes, and snippets.

@raster

raster/ArcOMatic

Created Nov 1, 2015
Embed
What would you like to do?
/*
* ArcOMatic
*
* pete@rasterweb.net
* http://rasterweb.net/raster/
*
*/
#include <Servo.h>
Servo ServoB;
Servo ServoL;
int total = 0;
void setup() {
Serial.begin(57600);
pinMode(13, OUTPUT);
ServoB.attach(9);
ServoL.attach(10);
Serial.println("Start");
ServoB.write(90);
ServoL.write(90);
digitalWrite(13, HIGH);
delay(4000);
digitalWrite(13, LOW);
delay(4000);
// set to home
for (int ctmp = 90; ctmp >= 45; ctmp -= 1) {
ServoB.write(ctmp);
delay(20);
}
for (int ctpm = 90; ctpm <= 180; ctpm += 1) {
ServoL.write(ctpm);
delay(20);
}
Serial.println("homed");
delay(10000);
}
void loop() {
int ctservobig = 55;
while (ctservobig < 125) {
ServoB.write(ctservobig);
if ((ctservobig >= 55) and (ctservobig < 59)) {
swinglittle(180, 75);
}
if ((ctservobig >= 60) and (ctservobig < 74)) {
swinglittle(180, 45);
}
if ((ctservobig >= 75) and (ctservobig < 89)) {
swinglittle(180, 10);
}
if ((ctservobig >= 90) and (ctservobig < 104)) {
swinglittle(180, 10);
}
if ((ctservobig >= 105) and (ctservobig < 117)) {
swinglittle(185, 10);
}
if ((ctservobig >= 118) and (ctservobig < 125)) {
swinglittle(185, 10);
}
ctservobig = ctservobig + 3;
delay(50);
}
delay(2000);
// reset to home
for (int ctmp = 125; ctmp >= 90; ctmp -= 1) {
ServoB.write(ctmp);
delay(50);
}
for (int ctpm = 105; ctpm >= 90; ctpm -= 1) {
ServoL.write(ctpm);
delay(50);
}
// if (total > 100) {
// loops forever... END!
while(1) {
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
//}
}
total++;
}
void swinglittle(int posHigh, int posLow) {
for (int ctsl = posHigh; ctsl >= posLow; ctsl -= 2) {
ServoL.write(ctsl);
delay(50);
}
for (int ctsl = posLow; ctsl <= posHigh; ctsl += 2) {
ServoL.write(ctsl);
delay(50);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.