• georgie h

Finally, the code works!!! (at its most basic level)

Below is an updated version of my projects code, I've used a combination of online examples to get the project working at its minimal viable outcome. Although not finalised as I still need to implement some of the messages in the code I will be using this as the bones of the project.


// Include the required Arduino libraries:
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
#include <Stepper.h>

//Based on the MAX7219 LED Matrix Display Arduino Tutorial (4 Examples) (makerguides.com) example code:

// Define hardware type, size, and output pins:
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 4
#define CS_PIN 3

//Initialise new class for MD_Parola, assigning hardware SPI connections:
MD_Parola ledMatrix = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);

//Variable for the number of steps per revolution.
const int stepsPerRevolution = 200; 

//Initialise the stepper motor using the Stepper class assigning it with its pins:
Stepper stepperMotor(stepsPerRevolution, 8, 9, 10, 12);

//Variable to hold the number of steps
int stepCounter = 0;

//CODE SET UP
void setup() {
  //Start the serial port (for keeping track of counting the steps)
  Serial.begin(9600);

  //SET UP FOR THE LED MATRIX
   ledMatrix.begin();
  // Control the brightness 
  ledMatrix.setIntensity(0);
  // Clears the display 
  ledMatrix.displayClear();
}

//REPEATING CODE
void loop() {
// Code based on the One Step At A Time example: https://www.arduino.cc/en/Tutorial/LibraryExamples/StepperOneStepAtATime
  //Make the stepper take 1 step at a time:
  stepperMotor.step(1);
  
  //Serial print
  Serial.print("Step Count:");
  Serial.println(stepCounter);
  
  //Incrementation to ensure steps go up 
  stepCounter++;

  //Delay between steps 
  delay(500);

  //if statement which communicates between the stepper and the ledmatrix
  if(stepCounter == 20)
    {
     ledMatrix.displayText("Scrolling text", PA_CENTER, 100, 0, PA_SCROLL_LEFT, PA_SCROLL_LEFT); 
    }

  delay(1000);

  if(stepCounter == 100)
    {
     ledMatrix.displayText("Another Text", PA_CENTER, 100, 0, PA_SCROLL_LEFT, PA_SCROLL_LEFT); 
    }

}

Next Steps:

+ Finalise the text, test that the timing works for each method and the movement of the stepper.

+ Ensure that the cranes platform is stable and the cranes do not fall over when turning

+ Work on getting more than one stepper working at a time

+ Document and reupload youtube video for this.

7 views0 comments

Recent Posts

See All

Exhibition Contribution

Exhibition Contribution Throughout the year I’ve played a key role in organising the exhibition, I’ve taken on a large amount of responsibility which is bulleted below: Set up the Notion Board to be u