as stated, getting compiler error , have no idea whats causing error. looks right me, though im not experienced in coding in language. board im using leonardo
here compiler error
code: [select]
#define delay 5 // delay per loop in ms
enum pinassignments
{
encoderpina = 0,
encoderpinb = 1,
encoderpinc = 3,
encoderpind = 2,
};
//this pin wiring
int encoderpos[] = {0,0};
static boolean rotating[] = {false,false};
boolean a_set = false;
boolean b_set = false;
boolean c_set = false;
boolean d_set = false;
void setup()
{
pinmode(4, input_pullup);
pinmode(a0, input_pullup);
pinmode(a1, input_pullup);
pinmode(a2, input_pullup);
pinmode(a3, input_pullup);
pinmode(a4, input_pullup);
pinmode(a5, input_pullup);
keyboard.begin();
pinmode(encoderpina, input_pullup);
pinmode(encoderpinb, input_pullup);
pinmode(encoderpinc, input_pullup);
pinmode(encoderpind, input_pullup);
attachinterrupt(0, doencoderc, change);
attachinterrupt(1, doencoderd, change);
attachinterrupt(2, doencodera, change);
attachinterrupt(3, doencoderb, change);
serial.begin(9600);
}
void loop() {
if(digitalread(4)==low){
keyboard.press('a');
}
if(digitalread(4)==high){
keyboard.release('a');
}
if(digitalread(a0)==low){
keyboard.press('b');
}
if(digitalread(a0)==high){
keyboard.release('b');
}
if(digitalread(a1)==low){
keyboard.press('c');
}
if(digitalread(a1)==high){
keyboard.release('c');
}
if(digitalread(a2)==low){
keyboard.press('d');
}
if(digitalread(a2)==high){
keyboard.release('d');
}
if(digitalread(a3)==low){
keyboard.press('i');
}
if(digitalread(a3)==high){
keyboard.release('i');
}
if(digitalread(a4)==low){
keyboard.press('f');
}
if(digitalread(a4)==high){
keyboard.release('f');
}
if(digitalread(a5)==low){
keyboard.press('g');
}
if(digitalread(a5)==high){
keyboard.release('g');
}
//encoder reset
for(int i=0;i<=1;i++)
{
rotating[i] = true;
if (encoderpos[i] != 0)
{
if(i==0) mouse.move(encoderpos[i],0,0);
if(i==1) mouse.move(0,encoderpos[i],0);
encoderpos[i] = 0;
}
}
delay(delay);
}
void doencodera()
{
if( digitalread(encoderpina) != a_set )
{
a_set = !a_set;
if ( a_set && !b_set )
encoderpos[0] += 1;
rotating[0] = false;
}
}
void doencoderb()
{
if( digitalread(encoderpinb) != b_set ) {
b_set = !b_set;
if( b_set && !a_set )
encoderpos[0] -= 1;
rotating[0] = false;
}
}
void doencoderc()
{
if( digitalread(encoderpinc) != c_set )
{
c_set = !c_set;
if ( c_set && !d_set )
encoderpos[1] += 1;
rotating[1] = false;
}
}
here compiler error
code: [select]
c:\program files (x86)\arduino\hardware\arduino\avr\cores\arduino\wiring.c: in function 'init':
c:\program files (x86)\arduino\hardware\arduino\avr\cores\arduino\wiring.c:318:3: warning: #warning timer 2 not finished (may not present on cpu) [-wcpp]
#warning timer 2 not finished (may not present on cpu)
^
c:\program files (x86)\arduino\hardware\arduino\avr\cores\arduino\wiring.c:327:3: warning: #warning timer 2 not finished (may not present on cpu) [-wcpp]
#warning timer 2 not finished (may not present on cpu)
^
c:\program files (x86)\arduino\hardware\arduino\avr\cores\arduino\tone.cpp:212:12: warning: #warning may not correct [-wcpp]
#warning may not correct
^
in file included c:\program files (x86)\arduino\hardware\arduino\avr\cores\arduino\usbapi.h:38:0,
from c:\program files (x86)\arduino\hardware\arduino\avr\cores\arduino\usbcore.cpp:19:
c:\program files (x86)\arduino\hardware\arduino\avr\cores\arduino\usbcore.cpp: in function 'bool sendconfiguration(int)':
c:\program files (x86)\arduino\hardware\arduino\avr\cores\arduino\usbcore.h:285:91: warning: narrowing conversion of 'interfaces' 'int' 'u8 {aka unsigned char}' inside { } ill-formed in c++11 [-wnarrowing]
{ 9, 2, _totallength,_interfaces, 1, 0, usb_config_bus_powered, usb_config_power_ma(500) }
^
c:\program files (x86)\arduino\hardware\arduino\avr\cores\arduino\usbcore.cpp:471:28: note: in expansion of macro 'd_config'
configdescriptor config = d_config(_cmark + sizeof(configdescriptor),interfaces);
^
avr-gcc: error: sketch_oct29a.cpp.o: no such file or directory
error compiling.
what board , ide version using?
other not having doencoderd() function, compiled fine due
other not having doencoderd() function, compiled fine due
Arduino Forum > Using Arduino > Programming Questions > Getting a compiler error with my code, no idea whats causing it.
arduino
Comments
Post a Comment