Thank-you. I've just tried that, and I get the exact same results as before. Misbehaviour on startup, LEDs initialise correctly, then just a high-pitched whine from the motor.
Here's my current code:
#include <AccelStepper.h>
#include <MultiStepper.h>
#include <Arduino.h>
#include <LedControl.h>
#define SENSOR_PIN 10 //For hall effect sensor
//LED output pins
#define GR_LED_PIN 4
#define RD_LED_PIN 5
//Motor control pins
#define MT_STEP 2
#define MT_DIR 3
AccelStepper turnMot(1, MT_STEP,MT_DIR);
//LED Display Pins
#define RO_CLK 7
#define RO_DIN 8
#define RO_LOAD 9
//Occupancy Sensor
#define OCC_PIN A0
//Below defines and creates the LED controller object
LedControl dispLED = LedControl(RO_DIN,RO_CLK,RO_LOAD,1);
void setup() {
//Set up the LED pins:
pinMode(GR_LED_PIN, OUTPUT);
pinMode(RD_LED_PIN, OUTPUT);
//Set up the hall effect sensor
pinMode(SENSOR_PIN, INPUT);
// put your setup code here, to run once:
//Initialise the LED controller
dispLED.shutdown(0,false);
/* Set the brightness to a medium values */
dispLED.setIntensity(0,12);
/* and clear the display */
dispLED.clearDisplay(0);
disNumLed (1234);
delay(1000);
dispLED.clearDisplay(0);
//Initialise the stepper motor
turnMot.setMaxSpeed(159);
turnMot.setSpeed(159);
//Calibrate the turntable
calibrateTurntable();
}
void loop() {
// put your main code here, to run repeatedly:
}
void calibrateTurntable(){
/*Below boolean acts as a flag as to
* whether the turntable should be
* calibrating or not.
*/
boolean turning = true;
while (turning){
turnMot.runToNewPosition(1);
delay(10);
if (digitalRead(SENSOR_PIN) == LOW){
turning = false;
}
}
}
void disNumLed (int disNum){
//Takes an integer and displays it on the 4-digit LED display
int firstDigit;
int secondDigit;
int thirdDigit;
int fourthDigit;
/*The 4-digit single module has digit 1 on left and 4 on the right. Hence,
* it needs to be added in reverse order. firstDigit to position 3, through
* to fourthDigit in position 0.
*/
dispLED.clearDisplay(0);
firstDigit = disNum % 10; //Return remainder of division operation (modulus)
dispLED.setDigit(0,3,firstDigit,false);
if (disNum > 9){
//If int is still greater than 9, then there should be another digit (base 10)
disNum /= 10; //Move to next digit
secondDigit = disNum % 10;
dispLED.setDigit(0,2,secondDigit,false);
}
if (disNum > 9){
disNum /= 10; //Move to next digit
thirdDigit = disNum % 10;
dispLED.setDigit(0,1,thirdDigit,false);
}
if (disNum > 9){
//Remainder would be above 10
disNum /= 10; //Move to next digit
fourthDigit = disNum; //As it's the only digit left
dispLED.setDigit(0,0,fourthDigit,false);
}
}