[Swansea Hackspace] code structure

Andy Davies andy at andydavies.info
Tue Feb 5 14:56:54 GMT 2019


Hi

Just wanted to check with you guys so see what would be the best way to structure some code.

I have four stepper motors controlled by a windows form via an Arduino.

One motor moves a camera on a lead screw forwards and backwards in order to take s stack of pictures. This happens each time there is a movement by one of the other stepper motors.

Stepper 2 – rotates a turntable on which the subject sits. Parameters are 1. direction (clockwise or anticlockwise); 2. number of steps to take to reach new position; 3. total number of moves.

Stepper 3 – moves the turntable left or right. Parameters are 1. direction (left or right); 2. number of steps to take to reach new position; 3. total number of moves.

Stepper 4 – inclines the subject. Parameters are 1. direction (tilt up or tilt down); 2. number of steps to take to reach new position; 3. total number of moves.

It may be that just one of steppers will move or a combination of all three at the same time or with one coming in for part of the movemnt of one of the others.

An integer is sent from the windows form to the Arduino to trigger the motors one step at a time:

1 moves camera forwards
2 moves camera backwards
4 moves turntable motor clockwise
5 moves turntable anticlockwise
6 tilt up
7 tilt down
8 left
9 right


Any suggestions as to how to structure the code will be most welcome.

Cheers

Andy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://swansea.hackspace.org.uk/pipermail/hackspace/attachments/20190205/35fd1fbc/attachment.html>


More information about the Hackspace mailing list