Gripporillat
Well-known member
Hi everybody!
I get this error but I can't figure it out:
"expected initializer before 'MIDIchannel'"
Your help will be highly appreciated!
Edit:
This is SkyController.h:
This is Skypoti.h
This is Skypoti.cpp
I get this error but I can't figure it out:
"expected initializer before 'MIDIchannel'"
Code:
#include "SkyController.h"
byte MIDIchannel = 1;
SkyPoti poti(A0, 1);
void setup() {
}
void loop() {
poti.send();
}
Your help will be highly appreciated!
Edit:
This is SkyController.h:
Code:
#ifndef SkyController_h
#define SkyController_h
#include "SkyPoti.h"
#endif
This is Skypoti.h
Code:
#ifndef SkyPoti_h
#define SkyPoti_h
#include "Arduino.h"
#define NOW true
class SkyPoti
{
public:
SkyPoti(int pin, int number);
void send(bool now=false);
private:
int _value;
int _pin;
int _number;
int read();
}
#endif
This is Skypoti.cpp
Code:
#include "Arduino.h"
#include "SkyPoti.h"
//Constructor
SkyPoti::Skypoti(int pin, int number) {
pinMode(pin, INPUT);
_pin = pin;
_value = 0;
_number = number;
}
//reads pin, converts into MIDI value and returns value
int SkyPoti::read() {
return round(analogRead(_pin)/(1023/127));
}
//sends directly if NOW, otherwise checks for alteration and sends if so
void SkyPoti::send(bool now) {
if (now) {
usbMIDI.sendControlChange(_number, _value, MIDIchannel);
} else if (this->read()!= _value) {
_value = this->read();
usbMIDI.sendControlChange(_number, _value, MIDIchannel);
}
}