Time - Lapse 2.0

Post Reply
DylanM
Maker in Training
Posts: 65
Joined: Sun Jun 22, 2014 8:39 pm
Location: Gelorup

Time - Lapse 2.0

Post by DylanM » Tue Dec 15, 2015 9:33 pm

Starting over with my time lapse box this time my code will use serial instead of pin pull ups and it should look a lot nicer with a 3d printed housing which I'm designing right now.
New code:
#include <Servo.h>

Servo servox;
int pos = 180;

byte byteRead;

void setup() {
// Turn the Serial Protocol ON
Serial.begin(9600);
pinMode(13, OUTPUT);
servox.attach(9);
}

void loop() {
byteRead = Serial.read();
servox.write(pos);


if (byteRead == 49)
{
pos = pos - 10;
digitalWrite(13, HIGH);
Serial.write("ON");
servox.write(pos);
}
else if (byteRead == 50)
{
pos = pos + 10;
digitalWrite(13, LOW);
Serial.write("OFF");
servox.write(pos);
}

}
I know everything about nothing.

Post Reply