/* * Motor Controller test program * A test program to control the outputs of the L298N driver * * Author: Harley Lara * Create: 01 May 2021 * License: (CC BY-SA 4.0) Attribution-ShareAlike 4.0 International * * This work may be reproduced, modified, distributed, * performed, and displayed for any purpose, but must * acknowledge this project. Copyright is retained and * must be preserved. The work is provided as is; no * warranty is provided, and users accept all liability. * */ /* Motor Pins Configuration * * ATtiny3216 | Fisical Pin | Prog | Arduino | Function | * | 12 | PA2 | 9 | IN1 | * Motor 1 Output 1 * | 11 | PA1 | 8 | IN2 | * Motor 1 Output 2 * | 13 | PA3 | 10 | IN3 | * Motor 2 Output 1 * | 4 | PA6 | 2 | IN4 | * Motor2 Output 2 * | 2 | PA4 | 0 | EN_A | * Ena ble Motor 1 * | 3 | PA5 | 1 | EN_B | * Enable Motor 2 */ int motor1pin1 = 9; int motor1pin2 = 8; int motor2pin1 = 10; int motor2pin2 = 2; int en_A = 0; int en_B = 1; void setup() { pinMode(motor1pin1, OUTPUT); pinMode(motor1pin2, OUTPUT); pinMode(motor2pin1, OUTPUT); pinMode(motor2pin2, OUTPUT); pinMode(en_A, OUTPUT); pinMode(en_B, OUTPUT); } void loop() { // Speed Controll => 0 = off and 255 = max speed analogWrite(en_A, 100); // EN_A pin // analogWrite(en_B, 200); // EN_B pin digitalWrite(motor1pin1, LOW); digitalWrite(motor1pin2, HIGH); digitalWrite(motor2pin1, LOW); digitalWrite(motor2pin2, HIGH); delay(1000); digitalWrite(motor1pin1, HIGH); digitalWrite(motor1pin2, LOW); digitalWrite(motor2pin1, HIGH); digitalWrite(motor2pin2, LOW); delay(1000); }