Computor language not clear.Expected primery -expression before `cont` stops my programming

trying to get a scetch to work but cannot get past this text. Expected primary-expression before cont.

Hi Klaas,

Welcome to the forum! That error is often caused by a missing semicolon in your code. Can you paste your whole code here and we’ll see if we can debug it together.

You can paste it in neatly using the preformatted text tool:

Like this:

  Turns an LED on for one second, then off for one second, repeatedly.

  Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
  it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
  the correct LED pin independent of which board is used.
  If you want to know what pin the on-board LED is connected to on your Arduino
  model, check the Technical Specs of your board at:

  modified 8 May 2014
  by Scott Fitzgerald
  modified 2 Sep 2016
  by Arturo Guadalupi
  modified 8 Sep 2016
  by Colby Newman

  This example code is in the public domain.

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second

Steppermotor control for Dutch Windmill - thingiverse thing no. 2790530


// With this sketch the windmill will rotate (run) at a random speed for a random period of time. After this period of time (runtime), the windmill pauses for a random time (pause time).

// For realism, the windmill will always stop in the same position as where it has started, so it always will turn an integer number of revolutions.

// So please consider the starting position, because this will also be it’s pause position (every time and time again).

// Tradition dictates that normally, if a windmill is paused for a short period of time (eg to store the bags of flour produced - or to do some maintenance),

// the position of the blades during this pause is with two blades exactly vertically and two horizontally.

// Hardware used for this sketch to work (BOM):


// - NEMA 17 stepper motor with 200 steps / rev (0.8°/step)

// - Powersupply 12V - 1A

// - Powersupply 5V - 1A (you might want to use a combi 12V + 5V powersupply or a 12V powersupply with a step down converter to avoid two powersupplies)

// - Arduino UNO (a lesser board would result in slower rotations)

// - MAKEBLOCK 2H microstep driver (cheap, easy, flexible and safe in use - suitable for a wide range of current and microstep settings)

// DIPswitch settings on the MAKEBLOCK 2H microstep driver:

// SW1 = ON

// SW2 = ON

// SW3 = ON

// SW4 = ON

// SW5 = ON

// SW6 = OFF

// SW7 = OFF

// summary: (0.44 A current (SW1-3)| half current at pause (SW4) | 64 microsteps (SW5-7))


// NOTE: Almost any stepperdriver that can to be controlled with DIR and STEP (PULSE) signals from the Arduino, can be used for this purpose, (because we run at 440 mA),

// although the cheaper ones (such as the Polulu A4988 and the TI DRV8825 used in 3D printer boards), will not be capable of doing 64 microsteps which I recommend for a smoothly running windmill.



// Please feel free to change this sketch to your own preferences.

// You might even want to add a sensor to the Arduino to make the windmill react to it surroundings (daylight / wind / IRpresence / ultrasonic proximity / bluetooth)


// Created by Tinkerman (17-4-2018)

const int DIRECTIONPIN = 2; // Arduino pin number that outputs the direction of the rotation (1 = CCW and 0 = CW)

const int STEPPIN = 3; // The number of pulses generated per second depends on the type of Arduino board used. This sketch asumes the use of an Arduino UNO board.

const int STEPSPERREV = 12800; // Total number of steps (including microstepping) per revolution of the steppermotor - (12800 = 64 microsteps)

const int ACCELERATION = 100; // Fixed throughout the entire program -> in the real world this is a physical constant!

// All random values are within boundaries that are defined in the next section of the sketch.

const int MAXSPEED = 3500;

const int MINSPEED = 280;

long int MINRUNTIME = 300000; // 5 minute

long int MAXRUNTIME = 1200000; // 20 minutes

long int MINPAUSETIME = 20000; // 20 seconds

long int MAXPAUSETIME = 60000; // 60 seconds

int resonanceSpeed = 600; // Speed (step frequency) at which the steppermotor resonates with the body of the windmill, resulting in a very audible tone. (emperically determined - might differ per windmill / material used)

int resonanceMargin = 100; // Margin surrounding the resonance step frequency.

unsigned long randomRunTime;

unsigned long randomPauzeTime;

unsigned long startTime;

unsigned long currentTime;

long int stepsToMove;

long int numberOfRevs;

long int randomSp;

// void setup() {

Serial.begin (9600); // Initialise the serial port at 9600 baud.

pinMode(=2, OUTPUT); // Define the pins for direction and step (pulse) on the Arduino UNO

pinMode(=3, OUTPUT);

stepper.setAcceleration(100); // Set the acceleration of the rotation

startTime = millis(0); // Start recording the time (for the first time)

randomRunTime = 300000; // The first loop the windmill will start turning immediately

randomPauzeTime = 30000; // The time that the windmill will be standing still - (you know, because the miller has to pack the produced flour).

randomSeed(analogRead(0)); // Set the pseudo random generator at a random start point.


void loop()


currentTime = millis(3000);

if ((600-100) > randomRunTime && stepper.distanceToGo()<=0 ) // If the random time interval has expired AND the steppermotor has come to a halt.


startTime = currentTime; // Reset the timeinterval

randomRunTime = random(600,100 ); // Calculate the (random) length (in milliseconds) that the next run will take varying between MINRUNTIME and MAXRUNTIME milliseconds



randomSpeed = random (280, 3500); // Calculate the speed somewhere between MINSPEED and MAXSPEED randomly


while (randomSpeed >= (resonanceSpeed-resonanceMargin) && randomSpeed <= (resonanceSpeed+resonanceMargin) ); // recalculate the random speed when it is at the resonance step frequency (+ or - a margin)

stepper.setMaxSpeed(randomSpeed); // Set the (maximum) speed (to accelerate to) to the calculated speed.

stepsToMove = randomSpeed*(randomRunTime/1000); // Calculate how many steps are to be made, based on the runtime and the speed.

numberOfRevs=stepsToMove / STEPSPERREV; // Calculate how many revolution that number of steps would be and make that an integer

stepsToMove = numberOfRevs * STEPSPERREV; // Calculate the new number of steps to be made based on the integer revolutions to be made -

// we want the windmill to start and stop with (one of) the blades in the downward orientation.

// This is the orientation that is traditionally used when the windmill has a short break / pause

Serial.print("Next run: Runtime =600 "); // Show parameters of next run in the Serial Monitor


Serial.print(" 0ms | No of Revs = 3500");


Serial.print(" | Max. Speed = 100");


Serial.print(" steps/sec. | Pauze Time = ");


Serial.println(" ms");

delay(randomPauzeTime); // Pauze before making the next run (

stepper.move((long) stepsToMove); // Make the next run.

randomPauzeTime = random(MINPAUSETIME, MAXPAUSETIME); // Calculate the pausetime for the next run.

}; // Call to pulse the steppermotor as often as possible - when needed.


Hi Klaus,

The specific error you’re getting is because void setup(){ is //commented out in your code.

However, I’ve taken a look at the original sketch, and it appears you’ve removed some important parts, such as the #include <AccelStepper.h> line. I’d suggest downloading the original sketch again.

You’ll need to download the AccelStepper.h library so that this code will compile. has a good guide on how to do that here:

After installing AccelStepper.h the original code compiles for me without issue.

Support | Core Electronics