Homework
The plank has spent the last month cluttering up my limited work space, while a storage cover was made. This proved to be some what of a problem with some minor warp-age insuring very few angles where 90 degrees however eventually this was resolved. The opportunity was taken to fit the crossing gate servos these been controlled via a Ardunio Micro given the required sequence required a slow opening of the first gate, a pause while the fireman crosses the road and then opens the second gate.
Hacking a simple Ardunio sketch appears to give the required sequence although final adjustments where time consuming.
for those intrested in such things I attach the code
/*
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/Button
*/
#include <VarSpeedServo.h>
VarSpeedServo myservo1; // create servo object to control a servo
// a maximum of eight servo objects can be created
VarSpeedServo myservo2; // create servo object to control a servo
// a maximum of eight servo objects can be created
// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 2; // the number of the pushbutton pin
const int servoPin1 = 9; // the digital pin used for the servo
const int servoPin2 = 6; // the digital pin used for the servo
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
// LED connected to digital pin 13
void setup() {
myservo1.attach(servoPin1); // attaches the servo on pin 9 to the servo object
myservo1.write(120,0,true); // set the intial position of the servo,
myservo2.attach(servoPin2); // attaches the servo on pin 9 to the servo object
myservo2.write(110,0,true); // set the intial position of the servo,
// initialize the servo pin as an output:
pinMode(servoPin1, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
void loop(){
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn servo on:
myservo2.write(110,2,true);
delay(6000); // waits for 6 seconds
myservo1.write(120,2,true);
}
else {
// turn servos off:
myservo1.write(55,2,true);
delay(6000); // waits for 6 econds
myservo2.write(55,2,true);
}
}
all a bit dry perhaps so some pictures and video to stop you falling asleep
- 4
7 Comments
Recommended Comments
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now