Hi! I am a 23 year old girl completely hopeless at coding! I am utterly new to it and can’t make it do what I want it to do! >:(

Basically, I have this rotary device that spins when plugged into a power source. I need the following: the device to ONLY rotate when a reed switch is activated, and for only 45 seconds. Interestingly, this rotary device works with morse code coding (it stops then starts etc) but when I try to code it for 45000 milliseconds it just keeps spinning and doesn’t stop. The morse code it works with is:

int ledPin=8;

void setup() {
// put your setup code here, to run once:

void loop() {
// put your main code here, to run repeatedly:

flash(200); flash(200); flash(200);
flash(500); flash(500); flash(500);
flash(200); flash(200); flash(200);

void flash(int duration)

ideally what I need is just ONE flash at 45 seconds then off until the reed switch is activated again, for another 45 seconds etc. (the flashes work as I have tested it, the rotary device comes with LED’s and so when the flash is on for 200 200 200, the spinning plate AND LED’s flash for that length of time. When I try to just do


it doesn’t work and just keeps it in a permanent on state! I have considered that I may need to use a relay but I have NO clue on that either!

Please help :slight_smile:


Your topic was Moved to it's current location / section as it is more suitable.

Could you also take a few moments to Learn How To Use The Forum.
Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

Basically, I have this rotary device that spins when plugged into a power source.

Please tell us what this rotary device actually is and what sort of power source you are using. If you can post a link to the datasheet for the device it would be a big help.

Do you mean that the device is being controlled by digital pin 13 (the LED pin)?

And if so do you mean that the device spins when pin 13 is HIGH and stops when it is LOW ?

I hope you are not connecting a motor directly to an Arduino I/O pin - that is likely to damage the Arduino.


Hi Robin2,

It is a little small display rotary device, when plugged into a 5v power supply it moves round very slowly and has LEDs that light up. It's just something we got online to try and rewire how we would like.

We had an arduino that had morse code loaded onto it, so connected the rotary plate to it, and it spun/flashed in time with the morse code that was on there. I want it to do this, but not quickly, it needs to be 45 seconds on then stop and thats it. I thought it would be really simple but I am surely doing something wrong?!

And that is what I would like it to do ideally. But when it is LOW it just seems to keep going and it doesn't pause at all? I can put it into whatever pin is easiest but I don't know which one!

Thanks, J x

Seeing as you got it online, can you post the link to the vendor's page?

Otherwise anyone trying to assist is just going to be guessing.

Or failing that of course, or even as well, some photos might help, especially if they show any maker's part numbers and so on.

While you are at it, please read the instructions for posting, notably at how to post actual code (item No.7) and modify your first post to provide a meaningful subject title. :grinning:

It is a little small display rotary device,

I can't visualize what you have - what size it is, how it gets connected to the power, what its purpose is etc etc etc

And what made you think that morse code is relevant?

Help us to help you.

Simple Image Posting Guide

The Morse code thing just runs the same i/o pin, no relevance really but it does mean you probably don’t need to worry about a relay.

Look at some of the simple examples and just see if you can just make it go and pause go and pause. Then look into how to track and handles changes on an input (you reed switch).

Your “just” flash/pause should work, 45 seconds on and 45 + 6 seconds off, or vice versa. If you don’t see why I think that’s what should happen, trace your finger through each line of the code includes going into the flash function.

Show us a hand drawn schematic and tell us what dies happen. You might get along faster if you cut the 45000 down. Try 10000.

This is dead simple, you won’t even need to think about denouncing the eeed switch as it will be not looked at fir way longer than it would. Bounce.