Jump to content






Photo
- - - - -

Homework

Posted by nick_bastable , 07 June 2015 · 1,204 views

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 :scratchhead: 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

Attached Image

Attached Image

  • Like x 4
  • Informative/Useful x 2





Nice work Nick.

That'll be the BLUE wire not the green that's doing that for you...there's a clue in there somewhere :lol:

Very clever. I expected the gates to open across the road. Forgive my ignorance but how do you talk to the Arduino. I presume the code has to be compiled. It has been some years but I used to write in C, Basic and assembler and have also input machine code direct. (you have to build your own timing loops for delays in machine code.

 

Don

Photo
richbrummitt
Jun 08 2015 12:26

It looks a lot like C++. There are presumably a large number of libraries?

Photo
nick_bastable
Jun 08 2015 17:33

Nice work Nick.

That'll be the BLUE wire not the green that's doing that for you...there's a clue in there somewhere :lol:

no greens down to earth....

 

 

Very clever. I expected the gates to open across the road. Forgive my ignorance but how do you talk to the Arduino. I presume the code has to be compiled. It has been some years but I used to write in C, Basic and assembler and have also input machine code direct. (you have to build your own timing loops for delays in machine code.

 

Don

 

 

It looks a lot like C++. There are presumably a large number of libraries?

 

 

code is a form of c/c++  the programmer / assembler is Java so should run on Windows/Linux/Apple  like all good things its open source and the libraries are quite extensive  I  upload via USB although it can be done by other methods

 

clone boards can be obtained via ebay for less than

Thanks Java was a bit after my time. I was using Boreland C compiler.

 

Don

Nick - great work. I've been thinking about doing the same sort of thing, after picking up an Arduino Uno recently and quickly getting it to control a couple of servos with minimal modifications to the free sample code provided. Such a great environment, just wish I could have been introduced to Arduinos and Raspberry PIs in my school days like many youngsters now!

 

I'm interested in your supporting electronics - I'm assuming this is to drive the power-hungry servos, but is there more to it than that? Do you have a circuit diagram?

 

Thanks!

Alan

Photo
nick_bastable
Jun 11 2015 21:06

Nick - great work. I've been thinking about doing the same sort of thing, after picking up an Arduino Uno recently and quickly getting it to control a couple of servos with minimal modifications to the free sample code provided. Such a great environment, just wish I could have been introduced to Arduinos and Raspberry PIs in my school days like many youngsters now!

 

I'm interested in your supporting electronics - I'm assuming this is to drive the power-hungry servos, but is there more to it than that? Do you have a circuit diagram?

 

Thanks!

Alan

Alan

 

you are correct,  the other bits are a simple 7805 based power supply  ( 12 volt DC is the master supply)  LED is only as a  visual indicator its working and the diode is simple short circuit protection

 

https://www.circuitl...enshot/540x405/

 

 

try using VarSpeedServo.h  its very useful

Recent Entries

My Gallery Albums

Recent Comments

Random Album Image

DSC 2524

user(s) viewing

members, guests, anonymous users

Search My Blog

MyBlogLog

Categories

Latest Visitors

  • Photo
    Adam
    Today, 14:37
  • Photo
    Hendreladis
    Today, 00:52
  • Photo
    TimothyB
    Yesterday, 15:19
  • Photo
    andy stroud
    18 Aug 2017 - 23:01
  • Photo
    Kris
    18 Aug 2017 - 18:20