comparison between signed and unsigned integer expressions [-Wsign-compare]

i have problem with using arduino

error sign like this

아두이노:1.8.9 (Windows 10), 보드:"Arduino Pro or Pro Mini, ATmega168 (3.3V, 8 MHz)"

D:\multiwii 자율비해\SensorBoard\SensorBoard.ino: In function 'void loop()':

D:\multiwii 자율비해\SensorBoard\SensorBoard.ino:101:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]

the code of void loop

void loop()
{
int duration, distance; //기본 변수 선언
int sum_of_distances = 0;

cli(); //stop interrupts

//Trig 핀으로 10us의 pulse 발생
digitalWrite(trigPin, LOW); //Trig 핀 Low
delayMicroseconds(2); //2us 유지
digitalWrite(trigPin, HIGH); //Trig 핀 High
delayMicroseconds(10); //10us 유지
digitalWrite(trigPin, LOW); //Trig 핀 Low

//Echo 핀으로 들어오는 펄스의 시간 측정
duration = pulseIn(echoPin, HIGH); //pulseIn함수가 호출되고 펄스가 입력될 때까지의 시간. us단위로 값을 리턴.

sei(); //allow interrupts

//음파가 반사된 시간을 거리로 환산
//음파의 속도는 340m/s 이므로 1cm를 이동하는데 약 29us.
//따라서, 음파의 이동거리 = 왕복시간 / 1cm 이동 시간 / 2 이다.
distance = duration / 29 / 2; //센치미터로 환산

if (distance > max_distance) {
distance = max_distance;
}

if (distance < min_distance) {
distance = max_distance;
}

//////filtering sonar error//////////////
sum_of_distances = 0;
for(int i = 0 ; i < sizeof(prev_distances) / sizeof(int) ; i++) {
sum_of_distances = sum_of_distances + prev_distances*;*

  • if(i > 0) {*
    prev_distances[i-1] = prev_distances*;
    _
    }_
    _
    }_
    distance = (distance + sum_of_distances) / ((sizeof(prev_distances) / sizeof(int)) + 1);
    prev_distances[(sizeof(prev_distances) / sizeof(int)) - 1] = distance;*

* ///////////////////////////////////////////*
* channel1.readSignal();*

* //Serial.print(distance);*
* //Serial.print(" ");*
* //Serial.print(channel1.getSignal());*
* //Serial.print(" ");*
* //Serial.print(sonarFrontDistanceWhileMissionCount);*
* //Serial.println();*
* if(1800 < channel1.getSignal()) {*
* if (GP_FRONT_SONAR_DISTANCE_OF_AVOID_WHILE_MISSION_MIN < distance*
* && distance < GP_FRONT_SONAR_DISTANCE_OF_AVOID_WHILE_MISSION_MAX) {
_
sonarFrontDistanceWhileMissionCount++;_
if(sonarFrontDistanceWhileMissionCount > GP_FRONT_SONAR_AVOID_WHILE_MISSION_COUNT_LIMIT) {
_
ppm[0] = 2300; //2300*_
* }*
* }*
* else {*
* ppm[0] = 1400;*
* sonarFrontDistanceWhileMissionCount = 0;*
* } *
* }*
* else {*
* ppm[0] = 1400; *
* }*

* // 1400 -> 1102*
* // 1800 -> 1500*
* // 2000 -> 1703*
* // 2300 -> 2000*
* // 2500 -> 2000*
* delay(delay_of_loop);
_
}_
ISR(TIMER1_COMPA_vect) { //leave this alone
_
cli(); //stop interrupts*_

* static boolean state = true;*
* TCNT1 = 0;*
* if (state) { //start pulse*
* digitalWrite(sigPin, onState);*
OCR1A = PPM_PulseLen * 2;
* state = false;*
* }*
* else { //end pulse and calculate when to start the next pulse*
* static byte cur_chan_numb;
static unsigned int calc_rest;
_
digitalWrite(sigPin, !onState);_
_
state = true;_
if (cur_chan_numb >= chanel_number) {
cur_chan_numb = 0;
calc_rest = calc_rest + PPM_PulseLen;//
OCR1A = (PPM_FrLen - calc_rest) * 2;
calc_rest = 0;
_
}_
_
else {_
OCR1A = (ppm[cur_chan_numb] - PPM_PulseLen) * 2;
calc_rest = calc_rest + ppm[cur_chan_numb];
cur_chan_numb++;
_
}_
_
}_
_
sei(); //allow interrupts*_
}
plz help us guys

(deleted)

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html . Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Please post your entire code.

Thanks.. Tom.. :slight_smile: