Help with making a sketch

Hi guys, I need some help with making a sketch to control 5 actuators and 2 electromagnets and 1 switch.

I am a complete novice at coding for arduino but i need to write a simple sketch just to demonstrate roughly what it would look like.

This basically means it doesn't actually have to work but it needs to look like it would if put in an arduino actually controlling the actuators, as the code is just for illustrative purposes for a university project. Just to clarify, this code will not be put into an arduino so it just has to look superficially correct.

If someone could give me an idea of how i would write this, or even better write up a quick sketch that i can use i would be eternally grateful!

The order of the actuators, each movement comes immediately after the previous one has finished, where the switch is the trigger for the whole process.

switch turns on
actuator 1 extends
actuator 2 extends
actuator 3 extends
electromagnet 1 turns on
electromagnet 2 turns on
actuator 3 retracts
actuator 4 rotates clockwise
electromagnet 1 turns off
actuator 5 extends
electromagnet 2 turns off
actuator 5 retracts
actuator 4 rotates anticlockwise
actuator 2 retracts
actuator 1 retracts

Hopefully this is enough information for someone to help me out. If needed i can supply more information.

Thanks in advance,

Hugo

This is a very strange request. You want someone to write some code that looks like it does something, but it doesn't matter if it doesn't work. How odd.

You may just as well submit your list of required actions for all the difference that it will make. Who will see the 'code' and how much do they know about programming ?

As I see a robot between the lines I suggest that you first go through the tutorial pages to get an understanding how the Arduino language works.
There are a lot of snippets there that are useful for your project - you will be inspired! - including magnets and relays etc.

One of the most important sketches is the "blink without delay" one which shows how to do subtasks under a certain condition (mostly time)

Essentially i need to show that i have conducted some preliminary tests on a simple robot design, so something i thought would be excellent is an arduino code. unfortunately i don't have an arduino to hand and i am running out of time, so i need to show that i have at least thought about how it might be coded, which is where 'it doesn't have to work' comes in, essentially i will be telling the reader 'this is what the code might look like' .
The person reading the report is a 'technical layman' with an understanding of control systems but likely no understanding of arduino code.
I have already been inspired by this forum and am planning to get an arduino uno when my semester has finished, but without sounding like an impatient ungrateful prat, I really don't have the time to learn the code having never looked at it before, as the deadline is looming and this is a minor element of a large project.
I have had a look at blink without delay, and it seems useful but i cant seem to figure out how to apply it to actuators as the output pins would be different (i think) and the names would be different, unless they are user specified.
Thanks

swiftech:
i need to show that i have at least thought about how it might be coded

I really don't have the time to learn the code having never looked at it before

These two requirements seem to be in conflict. I'm sure you agree that since this is work for academic credit, it needs to be YOUR work. In that case I suggest you avoid getting bogged down in the exact syntax of the programming language, since you don't know how to write code and don't seem to have time to learn. Instead, concentrate on describing the behaviour you want the code to have. One way to write this is by writing it in 'pseudocode'. This is English text that follows the same basic structure as your target language but is only intended to be human-readable and is not intended to compile. The description of the sequence of actions you included in your original post is a credible starting point, but it would be better to restructure it to represent a sequence of events and actions, rather than describing something that happened. For example:

wait for switch to turn on
retract actuators 1 through 3
turn on electromagnets 1 and 2
retract actuator 3
... etc

You don't seem to be using any inputs after the initial 'switch on' so, as described, the sequence would execute as fast as the actuators were capable of moving. If you intend this to be a simple timed sequence then that would be fine, given that commands like 'retract actuator' mean 'send the sequence of output signals at the correct timing to move the actuator the required distance at the required speed', with the intention that this command blocks (waits) until the movement is complete.

In practice, if you were really coding this, you might choose not to implement it in blocking code. Using a non-blocking approach would make it much easier to do several things simultaneously. However, it produces code which is more complex, and if you don't have time to understand simple code then you don't have time to understand more complex code.

so i need to show that i have at least thought about how it might be coded,

but you haven't.

but without sounding like an impatient ungrateful prat, I really don't have the time to learn the code having never looked at it before,

but you do. You are asking us to help you cheat, to act in a deception.

Still it is only Sunday so you have the rest of the day to actually read something. Go on deserve that qualification.

Your best bet at this time is likely a - flowchart!

In my opinion you would be better to face up to the fact that you have no program written and concentrate on demonstrating that you have thought about what it would do, in which order and what actions depend on others. A simple flowchart with boxes explaining actions and diamonds with yes/no outputs explaining decision points would be a good start.

you might try the gigs section ?

PeterH:
I'm sure you agree that since this is work for academic credit, it needs to be YOUR work. In that case I suggest you avoid getting bogged down in the exact syntax of the programming language, since you don't know how to write code and don't seem to have time to learn. Instead, concentrate on describing the behaviour you want the code to have. One way to write this is by writing it in 'pseudocode'. This is English text that follows the same basic structure as your target language but is only intended to be human-readable and is not intended to compile. The description of the sequence of actions you included in your original post is a credible starting point, but it would be better to restructure it to represent a sequence of events and actions, rather than describing something that happened. For example:

wait for switch to turn on
retract actuators 1 through 3
turn on electromagnets 1 and 2
retract actuator 3
... etc

You don't seem to be using any inputs after the initial 'switch on' so, as described, the sequence would execute as fast as the actuators were capable of moving. If you intend this to be a simple timed sequence then that would be fine, given that commands like 'retract actuator' mean 'send the sequence of output signals at the correct timing to move the actuator the required distance at the required speed', with the intention that this command blocks (waits) until the movement is complete.

In practice, if you were really coding this, you might choose not to implement it in blocking code. Using a non-blocking approach would make it much easier to do several things simultaneously. However, it produces code which is more complex, and if you don't have time to understand simple code then you don't have time to understand more complex code.

This sounds like exactly what i am after. I realise now that learning and writing a code is more work than i have time for even with some pointers from you guys, so this pseudocode works for me.

The blocking code seems to be what i am after as these steps are linear and there are no simultaneous actions.

Thanks a lot for the help, i wouldn't have even thought of doing it this way otherwise.

Grumpy_Mike:

so i need to show that i have at least thought about how it might be coded,

but you haven't.

but without sounding like an impatient ungrateful prat, I really don't have the time to learn the code having never looked at it before,

but you do. You are asking us to help you cheat, to act in a deception.

Still it is only Sunday so you have the rest of the day to actually read something. Go on deserve that qualification.

It was never my intention to cheat or take credit for others work, i suppose i just needed something to start me off. either way this pseudocode works perfectly for me.

Thanks for everyones help