error message/help with code.
error message , led messing code.
z:\arduino\voltage\voltage.ino: in function 'long int rgb(int, int, int)':
z:\arduino\voltage\voltage.ino:21:1: warning: no return statement in function returning non-void [-wreturn-type]
}
^
code below.
what im trying when 3 little caps reach @ 5 volts led suppose change colors each 1 gets full. blinking red green , repeat.
z:\arduino\voltage\voltage.ino: in function 'long int rgb(int, int, int)':
z:\arduino\voltage\voltage.ino:21:1: warning: no return statement in function returning non-void [-wreturn-type]
}
^
code below.
code: [select]
#define analog_in_ch1 0
#define analog_in_ch2 1
#define analog_in_ch3 2
const int rgbred = 2;
const int rgbgrn = 3;
const int rgbblu = 4;
void setup(){
serial.begin(19200);
pinmode(analog_in_ch1,input);
pinmode(analog_in_ch2,input);
pinmode(analog_in_ch3,input);
pinmode(rgbred,output);
pinmode(rgbgrn,output);
pinmode(rgbblu,output);
}
long rgb(int red, int green, int blue) {
analogwrite(rgbred, (red));
analogwrite(rgbgrn, (green));
analogwrite(rgbblu, (blue));
}
void loop(){
int val1 = analogread(analog_in_ch1);
int val2 = analogread(analog_in_ch2);
int val3 = analogread(analog_in_ch3);
int cnt = 0;
int v1 = map(val1,0,1023,0,5.0);
int v2 = map(val2,0,1023,0,5.0);
int v3 = map(val3,0,1023,0,5.0);
if(v1 >= 4.8 || v1 == -1){cnt = cnt+1;}
if(v2 >= 4.8 || v2 == -1){cnt = cnt+1;}
if(v3 >= 4.8 || v3 == -1){cnt = cnt+1;}
if(cnt == 0){
rgb(255,0,0);
}else if(cnt == 1){
rgb(255,165,0);
}else if(cnt == 2){
rgb(255,255,0);
}else if(cnt == 3){
rgb(0,255,0);
}
//serial.print(cnt);
serial.print('h'); /* unique header identify start of message */
serial.print(",");
serial.print(val1,dec);
serial.print(",");
serial.print(val2,dec);
serial.print(",");
serial.print(val3,dec);
serial.print(","); /* note comma sent after last field */
serial.println(); /* send cr/lf */
delay(90);
}
what im trying when 3 little caps reach @ 5 volts led suppose change colors each 1 gets full. blinking red green , repeat.
code: [select]
long rgb(int red, int green, int blue) {
analogwrite(rgbred, (red));
analogwrite(rgbgrn, (green));
analogwrite(rgbblu, (blue));
}
you promised compiler you'd return value function., didn't.
pants on fire.
Arduino Forum > Using Arduino > Programming Questions > error message/help with code.
arduino
Comments
Post a Comment