Fokkaði upp p2

This commit is contained in:
2026-09-17 12:20:06 +00:00
parent a54dbfbe2e
commit c355c232e6
9 changed files with 259 additions and 199 deletions
+49
View File
@@ -0,0 +1,49 @@
#include "motor_driver.h"
#include <avr/io.h>
MotorDriver::MotorDriver()
{
}
void MotorDriver::begin()
{
// Arduino D3 = PD3 = AIN1
// Arduino D11 = PB3 = AIN2
DDRD |= (1 << DDD3);
DDRB |= (1 << DDB3);
stop();
}
void MotorDriver::forward()
{
// AIN1 / D3 = HIGH
// AIN2 / D11 = LOW
PORTD |= (1 << PORTD3);
PORTB &= ~(1 << PORTB3);
}
void MotorDriver::reverse()
{
// AIN1 / D3 = LOW
// AIN2 / D11 = HIGH
PORTD &= ~(1 << PORTD3);
PORTB |= (1 << PORTB3);
}
void MotorDriver::stop()
{
// Both LOW
PORTD &= ~(1 << PORTD3);
PORTB &= ~(1 << PORTB3);
}