I am playing around with a motor using the pro mini board, trying to build a library to control the direction and pwm.
I followed some instructions on how to create the header files in the Arduino IDE but as I am using Arduino-mk on a Raspberry Pi to compile and upload the code, I think there's some missing steps and compilation goes wrong and throws me an error:
pi@zero:~/playg/arduino/hbridge $ ls
build-pro328 hbridge.cpp hbridge.h Makefile motorControl.ino upload
pi@zero:~/playg/arduino/hbridge $ make
...
In file included from hbridge.cpp:1:0:
hbridge.h:3:21: fatal error: arduino.h: No such file or directory
compilation terminated.
make: *** [/usr/share/arduino/Arduino.mk:1234: build-pro328/hbridge.cpp.o] Error 1
pi@zero:~/playg/arduino/hbridge $ more hbridge.h
#ifndef HBRIDGE_H
#define HBRIDGE_H
#include "arduino.h"
class HBridge {
public:
HBridge(int IN1, int IN2, int PWM);
void CW();
void CCW();
void changeFrequency(int frequency);
int _IN1, _IN2, _PWM;
};
#endif //HBRIDGE_H
pi@zero:~/playg/arduino/hbridge $ more hbridge.cpp
#include "hbridge.h"
HBridge::HBridge(int IN1, int IN2, int PWM){
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(PWM, OUTPUT);
_IN1 = IN1;
_IN2 = IN2;
_PWM = PWM;
}
void HBridge::CW(){
digitalWrite(_IN1, HIGH);
digitalWrite(_IN2, LOW);
}
void HBridge::CCW(){
digitalWrite(_IN1, LOW);
digitalWrite(_IN2, HIGH);
}
void HBridge::changeFrequency(int frequency){
analogWrite(_PWM, frequency);
}
pi@zero:~/playg/arduino/hbridge $ more Makefile
ARDUINO_DIR = /usr/share/arduino
BOARD_TAG = pro328
ARDUINO_PORT = /dev/ttyAMA0
ARDUINO_LIBS =
include /usr/share/arduino/Arduino.mk
I'm Guessing I'm missing the arduino header file or I need to link it within the Makefile or something. Appreciate the help.