5) Electronics and Software - RA


The electronics component of our build consists of a 12V DC motor, a 12V power supply, an Arduino Uno microcontroller, and an Arduino Motor Shield. The motor shield is mounted onto the microcontroller, and then the components are configured as follows (power supply instead of batteries):


The board controls the motor by running a program when the system is powered. This program writes a constant PWM value to the motor shield, driving the motor:


int directionPin = 12;
int pwmPin = 3;
int brakePin = 9;

void setup() {
  
//define pins
pinMode(directionPin, OUTPUT);
pinMode(pwmPin, OUTPUT);
pinMode(brakePin, OUTPUT);

}

void loop() {
digitalWrite(directionPin, HIGH);
//release breaks
digitalWrite(brakePin, LOW);

//spin the motor
analogWrite(pwmPin, 170);
}