I'm trying to create a class to control a servo.
#include <Servo.h>
class ServoInfo {
public:
byte min;
byte max;
byte pin;
ServoInfo(byte min, byte max, byte pin) {
min = min;
max = max;
pin = pin;
servo.attach(9);
}
void write(byte position) {
servo.write(position);
}
private:
Servo servo;
};
const ServoInfo SERVOS[] {
ServoInfo(25, 105, 9)
};
void setup() {
SERVOS[0].write(10);
}
void loop() { ; }
The problem I have that it doesn't work (or at least gives me compilation warnings):
C:\Users\banks\Documents\Arduino\RobotArm\RobotArm.ino: In function 'void setup()':
C:\Users\banks\Documents\Arduino\RobotArm\RobotArm.ino:29:21: warning: passing 'const ServoInfo' as 'this' argument discards qualifiers [-fpermissive]
SERVOS[0].write(10);
^
C:\Users\banks\Documents\Arduino\RobotArm\RobotArm.ino:16:10: note: in call to 'void ServoInfo::write(byte)'
void write(byte position) {
^~~~~
Sketch uses 1746 bytes (5%) of program storage space. Maximum is 32256 bytes.
Global variables use 53 bytes (2%) of dynamic memory, leaving 1995 bytes for local variables. Maximum is 2048 bytes.
--------------------------
Compilation complete.
What is this error trying to tell me? I get the feeling that is something to do with the .
,->
or ::
but I don't know what. I'm a C# developer, so to me everything is a .
.