SlotForum banner

A working start finish/flag waver?

4320 Views 29 Replies 8 Participants Last post by  Ade
I am sure I’ve seen a post in the past showing how to create a chequered flag waver ( maybe dreamt it!), but can’t find anything substantial on the topic.
I am keen to try and create a modern flag waver for the Magneticracing flag waver cage.
Arduino sketch to control it ? -I use PCLC
Any help guidance much appreciated as ever.
Tim
1 - 15 of 30 Posts
Hi Heath
A little guy that waves a flag is exactly what I’m interested in!
PS How is the blimp progressing?
Tim
At present I have a working start light gantry ( 1 2 3 4 5 red lights , then 3 green on for duration of race which go out as the winner crosses the line ) controlled by an Arduino Uno and the PCLC rms.
The question is how do I use the green off to trigger an arm waving figure?
Another Arduino or can I somehow use the one I have ( I am a novice)?
Unfortunately I can’t write sketches !!
Any help/advice would be be very much appreciated
Tim
Thanks for the replies so far.
I’m really after a modern figure to wave the flag if possible ( I have the old Scalextric rostrum and starter which is rather dated.)
The figure is really the icing on the cake, at the end of the project - solving the automation using an Arduino is my major problem.
Can my existing sketch for running the start lights through PCLC be modified to trigger a servo when the green lights go off at the end of a race? If so, can anybody help me achieve this?
If not,do I need another arduino programmed to trigger the servo when the ‘green lights off’ signal comes through.
I can’t write code for Arduinos, so any help would be very much appreciated.
Tim
Hi Heath
Good to hear from you.
What you say about hopefully using the same Arduino sounds very promising.
The little guy’s pin is set to high within the code at the point where the race finishes powers up the servo which can presumably be set for few seconds - almost sounds as though I know what I’m talking about!!!
Do you code Arduino?
If you do could I send you the sketch to have a look at - if not no worries.
All the best
Tim
Hi Drifter
I’ll send you the sketch that Geoff 997 wrote a few years ago, that I use with PCLC.
Hopefully you can help 🤞
Tim
4
A couple of weeks since picking up my MagneticRacing flag waver rostrum at Gaydon and the project is complete.
Firstly, a very big thank you to Clive (aka Drifter2) who answered my plea for someone who could modify my start light Arduino sketch. (The version I use was last modified by GregK back in 2014). In a very short time an email arrived from Clive in Sydney,with the updated sketch attached (the wonder of modern tech!).
Now at the end of a race ,when PCLC turns off the green lights ,a servo is triggered that moves the flag waver’s arm for 5 seconds - just what I wanted!

For me the hard part has been the flag waver himself!
With no adequate 1:32 figure available I ended up “butchering” an Airfix 1:32 WW2 American Marine with Dremel etc. and filler. A new head ,courtesy of a cheap Gaydon purchase and the transformation was complete.
Here are some pictures and a link to a very short video.
Toy Gesture Statue Hat Art
Gesture Toy Wall Art Sculpture
Hat Toy Wood Outdoor play equipment Building
Photograph White Mode of transport Hat Red

With regards to the sketch,Clive is very happy for this to be shared.
Tim
See less See more
Hopefully this video link works!
Thanks Ade- it is such great fun to do and so satisfying!
What next is the question?
This time of year is project time for me and the success of the flag waver has got me thinking !
It would be great if I could hook up ,say three yellow flag waving marshalls, on a bend who could be triggered to wave in sequence.
PCLC already fires up flashing yellow lights around the track through an Arduino Uno ,when the race director hits the yellow flag button - so I’m hoping that with the correct extra bit of code in the sketch this could be used to also trigger servos to work in sequence, while the yellow flag call is on.
I would very much appreciate it if anybody could take a look at this for me (as I'm not a coder!!:()
Here is the current sketch to look at:-



//start
// define which pins are to be used for the various light functions
#define GREEN1 12 //edit for your green pin
#define AMBER1 11 //edit for your amber/yellow pin
#define AMBER2 2 //edit for your amber/yellow pin // Extra amber light output - Greg Kilkenny, 08/04/18
#define RED1 10 //edit for your 5th red pin
#define RED2 9 //edit for your 4th red pin
#define RED3 8 //edit for your 3rd red pin
#define RED4 7 //edit for your 2nd red pin
#define RED5 6 //edit for your 1st red pin
#define BLUE1 5 //edit for your blue pin
#include <Servo.h>

int amberswPin = 4;//edit to be any unused digital pin
int blueswPin = 3;//edit to be any unused digital pin
int ledPin = 13;
unsigned long nextBlink;
char amberswState = LOW;
char blueswState = LOW;
char ledState = LOW;
int CarsInPits = 0;


Servo myservo; // create servo object to control a servo
// twelve servo objects can be created on most boards
bool Green_State = 0;
int pos = 0; // variable to store the servo position

// setup the pins for outputs, blinking and open the serial port
void setup()
{
myservo.attach(A0); // attaches the servo on pin A0 to the servo object (change to suit your setup)
myservo.write(0); // tell servo to go to Zero position in degrees 0-90
pinMode(GREEN1, OUTPUT);
pinMode(RED1, OUTPUT);
pinMode(RED2, OUTPUT);
pinMode(RED3, OUTPUT);
pinMode(RED4, OUTPUT);
pinMode(RED5, OUTPUT);
pinMode(AMBER1, OUTPUT);
pinMode(AMBER2, OUTPUT);
pinMode(BLUE1, OUTPUT);
pinMode(ledPin, OUTPUT);
amberswState = LOW;
ledState = LOW;
nextBlink = millis();
Serial.begin(9600);
}


void blink (void)
{
unsigned long now;
now = millis();
if (now >= nextBlink)
{
nextBlink = now + 1000; // Next change in one second or edit value 1000 to prefered milliseconds
if (ledState == LOW) {digitalWrite(ledPin, HIGH); ledState = HIGH;} else {digitalWrite(ledPin, LOW); ledState = LOW;}
}
}


// look for data on the serial port and turn on/off the lights - data is ascii strings
void loop()
{
blink();
if (ledState == HIGH && amberswState == HIGH) {digitalWrite (AMBER1, HIGH); digitalWrite (AMBER2, HIGH);digitalWrite(GREEN1, LOW);}
else {digitalWrite (AMBER1, LOW); digitalWrite (AMBER2, LOW);} // GPK
if (ledState == LOW && amberswState == HIGH) {digitalWrite (AMBER1, LOW); digitalWrite (AMBER2, LOW);} // GPK
if (ledState == HIGH && blueswState == HIGH) {digitalWrite (BLUE1, HIGH);}
else {digitalWrite (BLUE1, LOW);}
if (ledState == LOW && blueswState == HIGH) {digitalWrite (BLUE1, LOW);}

if ( Serial.available() )
{
String b;
b = Serial.readStringUntil('[');
{
String s;

s = Serial.readStringUntil(']');
if ( s == "SL010" ) { digitalWrite(RED1, LOW); }
if ( s == "SL011" ) { digitalWrite(RED1, HIGH); }
if ( s == "SL020" ) { digitalWrite(RED2, LOW); }
if ( s == "SL021" ) { digitalWrite(RED2, HIGH); }
if ( s == "SL030" ) { digitalWrite(RED3, LOW); }
if ( s == "SL031" ) { digitalWrite(RED3, HIGH); }
if ( s == "SL040" ) { digitalWrite(RED4, LOW); }
if ( s == "SL041" ) { digitalWrite(RED4, HIGH); }
if ( s == "SL050" ) { digitalWrite(RED5, LOW); }
if ( s == "SL051" ) { digitalWrite(RED5, HIGH); digitalWrite(RED1, LOW);
digitalWrite(RED2, LOW); digitalWrite(RED3, LOW);
digitalWrite(RED4, LOW); digitalWrite(AMBER1, LOW); digitalWrite (AMBER2, LOW); // GPK
digitalWrite(GREEN1, LOW);}
if ( s == "SL060" ) { digitalWrite(GREEN1, LOW); }
if ( s == "SL061" ) { digitalWrite(GREEN1, HIGH); }
if ( s == "SL080" ) { digitalWrite(amberswPin, LOW); amberswState = LOW; digitalWrite(GREEN1, HIGH);}
if ( s == "SL081" ) { digitalWrite(amberswPin, HIGH); amberswState = HIGH;}
if ( s == "PT010" ) { CarsInPits-- ;} // A car just left the pits, minus one car from CarsInPits count
if ( s == "PT011" ) { CarsInPits++ ;} // A car just entered the pits, plus one car to CarsInPits count
if ( s == "PT020" ) { CarsInPits-- ;}
if ( s == "PT021" ) { CarsInPits++ ;}
if ( s == "PT030" ) { CarsInPits-- ;}
if ( s == "PT031" ) { CarsInPits++ ;}
if ( s == "PT040" ) { CarsInPits-- ;}
if ( s == "PT041" ) { CarsInPits++ ;}
if ( s == "PT050" ) { CarsInPits-- ;}
if ( s == "PT051" ) { CarsInPits++ ;}
if ( s == "PT060" ) { CarsInPits-- ;}
if ( s == "PT061" ) { CarsInPits++ ;}

if (CarsInPits <= 0 )
{ //if there are zero cars in the pit, turn off the blue lights
digitalWrite(blueswPin, LOW); blueswState = LOW;
}
else
{ // if there is one or more cars in the pit , keep the blue lights going
digitalWrite(blueswPin, HIGH); blueswState = HIGH;
}
if (CarsInPits < 0 || CarsInPits > 6) {CarsInPits = 0; } //if number of cars in pits gets messed up reset to zero [ '||' = 'or' ]
//Serial.println(CarsInPits); //debug
}
}
if (digitalRead(GREEN1) ){ //test if green is on and save
Green_State = 1 ;
}

if ((digitalRead(GREEN1)==0 ) && ( Green_State == 1 )){ //test if green is off but was on
if (amberswState == LOW){ //make sure we are not in a track call
Green_State = 0 ;
Wave_Flag (); ///wave the flag
}
}
} //end main loop

void Wave_Flag () {
for(int b=0; b<5; b ++){ //loop 5 times ( 5 x 500ms x 2 >>= 5000ms = 5 Seconds
myservo.write(180); // tell servo to go to position in degrees 0-180
delay(500); // give it time to get there
myservo.write(0); // tell servo to go to position in degrees 0-180
delay(500); // give it time to get there
}
}
//end

Tim

Attachments

See less See more
Prettier than the normal marshall !
2
Just finished off part two of the project- to have yellow flag waving marshalls triggered by the yellow lag/safety car call in PCLC. Switched the chequered flag waver to the UNO’s 3.3 v supply and it is fine. This left the one remaining 5v supply to power 3 servos for the marshalls connected in parallel. I wasn’t sure if this would work but encouraged by Ade ( thanks yet again) I gave it a go and fortunately everything is fine. I’ve got one spare servo, so I’ll make up one more figure and see if 4 is ok.🤞
The marshalls again started out life as WW2 Airfix figures (German grenade throwers!) -then modified with Milliput and Isopon.
A couple of pictures and a short video- the only down side is the noise made by the servos ,but they’ll never be on for very long at any one time.


Toy Art Sculpture Action figure Fictional character
Automotive tire Fence Asphalt Road surface Font
See less See more
  • Like
Reactions: 3
Amazingly four marshalls ie 4 servos work fine,off just one 5volt Arduino pin!
Happy days😀!
  • Like
Reactions: 1
10
Having now made and powered up,8 yellow flag wavers around the track- 3 from the 5v UNO output and the rest with the aid of an extra external 5v supply, I turned to the issue of better Safety Car warning lights. I really like the MAX 7219 8x8 led matrix modules. They are only 30mm x30mm and so great for 1:32 scale and look really good.
As adapting my existing start light sketch was going to be too complicated, I decided that a simple on/off push button for the safety car lights would be fine - the safety car itself is sent out round the track in a similar fashion.
Using some spare bits from some recent Magneticracing builds - plus the brushed metal tube of a garden solar light, I made some housings for the matrix modules.
The control is by an arduino UNO plus external 5v supply with an adaptation of a basic sketch I found online.
Having got the ‘bug’ I made an extra housing for a ‘Pit In‘ flashing sign - used the same adapted sketch this time with an Arduino NANO powered from the same 5v supply.
As ever all great fun and inexpensive!
Here are some pictures and another very short video


Audio equipment Electric blue Cable Pattern Gadget
Rectangle Wood Outdoor furniture Grass Road surface
Water Wood Land lot Natural landscape Grass
Hood Automotive tire Automotive lighting Bicycle tire Line
Automotive lighting Hood Automotive tire Grille Bumper
Car Road surface Asphalt Urban design Mode of transport

Tim

Attachments

See less See more
  • Like
  • Wow
Reactions: 4
1 - 15 of 30 Posts
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.
Top