Go Down

Topic: Ошибка:expected unqualified-id before 'else' нужна помощь! (Read 473 times) previous topic - next topic

neznayka_V_shlape

Программировать начал недавно (arduino UNO), помогите пож исправить ошибку!
error: ожидается неквалифицированный идентификатор до «else»
 
пишу прогу "Управляемый ночник на светодиоде ( с RGB-светодиодом)"
вот фрагмент кода( ошибка на последнем else):

Code: [Select]

void setMode( int mode)
{
  // КРАСНЫЙ
  if (mode ==1)
  digitalWrite(RLED, HIGH);     
digitalWrite(GLED, LOW);
digitalWrite(BLED, LOW);
  }
// зеленый
else if( mode==2)
{
digitalWrite(RLED, LOW);
digitalWrite(GLED,HIGH );
digitalWrite(BLED, LOW);
}

// синий
else if( mode==3)
{
digitalWrite(RLED, LOW);
digitalWrite(GLED, LOW);
digitalWrite(BLED, HIGH);
}
//ПУРПУРНЫЙ КР+С
else if( mode==3)
{
digitalWrite(RLED, 127);
digitalWrite(GLED, 0);
digitalWrite(BLED, 127);
}
//бирюзовый с+зел
else if( mode==4)
{
digitalWrite(RLED, 127);
digitalWrite(GLED, 0);
digitalWrite(BLED, 127);
}
//ОРАНЖЕВЫЙ ЗЕЛ+КР
else if( mode==5)
{
digitalWrite(RLED, 127);
digitalWrite(GLED, 127);
digitalWrite(BLED, 0);
}
// БЕЛЫЙ  ЗЕЛ+КР+С
else if( mode==6)
{
digitalWrite(RLED, 127);
digitalWrite(GLED, 127);
digitalWrite(BLED, 127);
}

 else
 {
digitalWrite(RLED, LOW);
digitalWrite(GLED, LOW);
digitalWrite(BLED, LOW);
 }
}

arduarn

You will annoy folks here by posting multiple times with the same problem. Stick to the one thread per issue!

кстати, форум по-рускии

ChrisTenone

You also may want to post in the Russian language section, because most folks here can't read your post.
Atmosphere carries combustion vapors to places where they will do good instead of harm - Mike Faraday's 'History of a Candle': https://www.youtube.com/watch?v=6W0MHZ4jb4A

Whoops ::)

sterretje

If you properly indent your code (use tools-> autoformat in the IDE), your problem can be seen straight away. Your have a mismatch between { and }.
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

Go Up