Нужна помощь. Ошибка загрузки программы.

Тема в разделе "Arduino & Shields", создана пользователем grigin, 4 янв 2017.

  1. grigin

    grigin Нуб

    Добрый день! Есть проблема с технокотом. Собрал по инструкции модельку, подключил к компу, проверил - живая, огонёк светится. Начал писать самый простой код (гирлянда, исполняющая песенку) сам, следуя листингу. Дописал, определил его в Arduino IDE, как Arduino Leonardo, как того требует инструкция. Подключил порт. Нажал Ctrl + U - пишет - "Low memory available, stability problems may occur" и вылетает. Не понятно откуда берется Low memory, если Эта Iskra Neo только что из коробки и на неё ещё ничего не загружали! Плюнул на свой код, скачал прямо с сайта. Загрузил. Пишет вот такое:

    "Sketch uses 8,802 bytes (30%) of program storage space. Maximum is 28,672 bytes.
    Global variables use 2,019 bytes (78%) of dynamic memory, leaving 541 bytes for local variables. Maximum is 2,560 bytes.
    Low memory available, stability problems may occur.
    An error occurred while uploading the sketch"

    Чего делать? Менял провод по которому загружаю, Пере-подключал модули. По-прежнему не работает!
    Заранее спасибо! Буду очень признателен за помощь!
     
  2. ZAZ-965

    ZAZ-965 Гуру

    @grigin, если речь идет о Технокотике попробуйте разместить массивы во flash памяти, используя модификатор переменной const PROGMEM
    Код (C++):
    //измененные и добавленные строки
    //подключаем библиотеку
    #include <avr/pgmspace.h>

    //размещаем ноты в памяти
    const PROGMEM int melody[] =

    const PROGMEM int noteDurations[] =
     
  3. grigin

    grigin Нуб

    Да-да о нём самом, сейчас попробую
     
  4. grigin

    grigin Нуб

    Добрый День! К сожалению по-прежнему не работает! Ошибку low memory не выдаёт, теперь пишет просто вот так:
    "
    Sketch uses 8,802 bytes (30%) of program storage space. Maximum is 28,672 bytes.
    Global variables use 183 bytes (7%) of dynamic memory, leaving 2,377 bytes for local variables. Maximum is 2,560 bytes.
    An error occurred while uploading the sketch"
    Что делать?
     
  5. Arduino подключена к порту который указан? Если нет, то делай так:
    1. Зайди в диспечер устройств.
    2.Найди "Порты COM и LPT"
    3. Открой Ардуино уно ( свойства)
    4. Параметры порта
    5. Дополнительно.....
    6.Номер потра - COM 1
     
  6. grigin

    grigin Нуб

    Да! Подключена, но не работает!
     
  7. ZAZ-965

    ZAZ-965 Гуру

    @grigin, какая у вас версия Arduino IDE? Только вчера проверял на Leonardo и IDE 1.80 http://forum.amperka.ru/threads/nyan.10334/ Чтобы увидеть подробные сообщения включите в IDE в настойках галочки - Подробный вывод компиляция + загрузка.
     
  8. grigin

    grigin Нуб

    Версия 1.6.10. И iskra neo
     
  9. grigin

    grigin Нуб

    Вот код:
    #include <avr/pgmspace.h>
    #define REST 0
    #define NOTE_B0 31
    #define NOTE_C1 33
    #define NOTE_CS1 35
    #define NOTE_D1 37
    #define NOTE_DS1 39
    #define NOTE_E1 41
    #define NOTE_F1 44
    #define NOTE_FS1 46
    #define NOTE_G1 49
    #define NOTE_GS1 52
    #define NOTE_A1 55
    #define NOTE_AS1 58
    #define NOTE_B1 62
    #define NOTE_C2 65
    #define NOTE_CS2 69
    #define NOTE_D2 73
    #define NOTE_DS2 78
    #define NOTE_E2 82
    #define NOTE_F2 87
    #define NOTE_FS2 93
    #define NOTE_G2 98
    #define NOTE_GS2 104
    #define NOTE_A2 110
    #define NOTE_AS2 117
    #define NOTE_B2 123
    #define NOTE_C3 131
    #define NOTE_CS3 139
    #define NOTE_D3 147
    #define NOTE_DS3 156
    #define NOTE_E3 165
    #define NOTE_F3 175
    #define NOTE_FS3 185
    #define NOTE_G3 196
    #define NOTE_GS3 208
    #define NOTE_A3 220
    #define NOTE_AS3 233
    #define NOTE_B3 247
    #define NOTE_C4 262
    #define NOTE_CS4 277
    #define NOTE_D4 294
    #define NOTE_DS4 311
    #define NOTE_E4 330
    #define NOTE_F4 349
    #define NOTE_FS4 370
    #define NOTE_G4 392
    #define NOTE_GS4 415
    #define NOTE_A4 440
    #define NOTE_AS4 466
    #define NOTE_B4 494
    #define NOTE_C5 523
    #define NOTE_CS5 554
    #define NOTE_D5 587
    #define NOTE_DS5 622
    #define NOTE_E5 659
    #define NOTE_F5 698
    #define NOTE_FS5 740
    #define NOTE_G5 784
    #define NOTE_GS5 831
    #define NOTE_A5 880
    #define NOTE_AS5 932
    #define NOTE_B5 988
    #define NOTE_C6 1047
    #define NOTE_CS6 1109
    #define NOTE_D6 1175
    #define NOTE_DS6 1245
    #define NOTE_E6 1319
    #define NOTE_F6 1397
    #define NOTE_FS6 1480
    #define NOTE_G6 1568
    #define NOTE_GS6 1661
    #define NOTE_A6 1760
    #define NOTE_AS6 1865
    #define NOTE_B6 1976
    #define NOTE_C7 2093
    #define NOTE_CS7 2217
    #define NOTE_D7 2349
    #define NOTE_DS7 2489
    #define NOTE_E7 2637
    #define NOTE_F7 2794
    #define NOTE_FS7 2960
    #define NOTE_G7 3136
    #define NOTE_GS7 3322
    #define NOTE_A7 3520
    #define NOTE_AS7 3729
    #define NOTE_B7 3951
    #define NOTE_C8 4186
    #define NOTE_CS8 4435
    #define NOTE_D8 4699
    #define NOTE_DS8 4978

    #define LED_R 10
    #define LED_Y 3
    #define LED_G 9
    #define LED_B 4
    #define BUZZER 2
    #define BUTTON 8


    // Массив с нотами мелодии

    const PROGMEM int melody[] = {
    NOTE_DS5, NOTE_E5, NOTE_FS5, 0, NOTE_B5, NOTE_E5, NOTE_DS5, NOTE_E5, NOTE_FS5, NOTE_B5, NOTE_DS6, NOTE_E6, NOTE_DS6, NOTE_AS5, NOTE_B5, 0,
    NOTE_FS5, 0, NOTE_DS5, NOTE_E5, NOTE_FS5, 0, NOTE_B5, NOTE_CS6, NOTE_AS5, NOTE_B5, NOTE_CS6, NOTE_E6, NOTE_DS6, NOTE_E6, NOTE_CS6,
    NOTE_FS4, NOTE_GS4, NOTE_D4, NOTE_DS4, NOTE_FS2, NOTE_CS4, NOTE_D4, NOTE_CS4, NOTE_B3, NOTE_B3, NOTE_CS4,
    NOTE_D4, NOTE_D4, NOTE_CS4, NOTE_B3, NOTE_CS4, NOTE_DS4, NOTE_FS4, NOTE_GS4, NOTE_DS4, NOTE_FS4, NOTE_CS4, NOTE_DS4, NOTE_B3, NOTE_CS4, NOTE_B3,
    NOTE_DS4, NOTE_FS4, NOTE_GS4, NOTE_DS4, NOTE_FS4, NOTE_CS4, NOTE_DS4, NOTE_B3, NOTE_D4, NOTE_DS4, NOTE_D4, NOTE_CS4, NOTE_B3, NOTE_CS4,
    NOTE_D4, NOTE_B3, NOTE_CS4, NOTE_DS4, NOTE_FS4, NOTE_CS4, NOTE_D4, NOTE_CS4, NOTE_B3, NOTE_CS4, NOTE_B3, NOTE_CS4,
    NOTE_FS4, NOTE_GS4, NOTE_D4, NOTE_DS4, NOTE_FS2, NOTE_CS4, NOTE_D4, NOTE_CS4, NOTE_B3, NOTE_B3, NOTE_CS4,
    NOTE_D4, NOTE_D4, NOTE_CS4, NOTE_B3, NOTE_CS4, NOTE_DS4, NOTE_FS4, NOTE_GS4, NOTE_DS4, NOTE_FS4, NOTE_CS4, NOTE_DS4, NOTE_B3, NOTE_CS4, NOTE_B3,
    NOTE_DS4, NOTE_FS4, NOTE_GS4, NOTE_DS4, NOTE_FS4, NOTE_CS4, NOTE_DS4, NOTE_B3, NOTE_D4, NOTE_DS4, NOTE_D4, NOTE_CS4, NOTE_B3, NOTE_CS4,
    NOTE_D4, NOTE_B3, NOTE_CS4, NOTE_DS4, NOTE_FS4, NOTE_CS4, NOTE_D4, NOTE_CS4, NOTE_B3, NOTE_CS4, NOTE_B3, NOTE_B3,
    NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_CS4, NOTE_DS4, NOTE_B3, NOTE_E4, NOTE_DS4, NOTE_E4, NOTE_FS4,
    NOTE_B3, NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_FS3, NOTE_E4, NOTE_DS4, NOTE_CS4, NOTE_B3, NOTE_E3, NOTE_DS3, NOTE_E3, NOTE_FS3,
    NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_B3, NOTE_CS4, NOTE_DS4, NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_FS3,
    NOTE_B3, NOTE_B3, NOTE_AS3, NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_E4, NOTE_DS4, NOTE_E4, NOTE_FS4, NOTE_B3, NOTE_AS3,
    NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_CS4, NOTE_DS4, NOTE_B3, NOTE_E4, NOTE_DS4, NOTE_E4, NOTE_FS4,
    NOTE_B3, NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_FS3, NOTE_E4, NOTE_DS4, NOTE_CS4, NOTE_B3, NOTE_E3, NOTE_DS3, NOTE_E3, NOTE_FS3,
    NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_B3, NOTE_CS4, NOTE_DS4, NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_FS3,
    NOTE_B3, NOTE_B3, NOTE_AS3, NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_E4, NOTE_DS4, NOTE_E4, NOTE_FS4, NOTE_B3, NOTE_CS4,
    NOTE_FS4, NOTE_GS4, NOTE_D4, NOTE_DS4, NOTE_FS2, NOTE_CS4, NOTE_D4, NOTE_CS4, NOTE_B3, NOTE_B3, NOTE_CS4,
    NOTE_D4, NOTE_D4, NOTE_CS4, NOTE_B3, NOTE_CS4, NOTE_DS4, NOTE_FS4, NOTE_GS4, NOTE_DS4, NOTE_FS4, NOTE_CS4, NOTE_DS4, NOTE_B3, NOTE_CS4, NOTE_B3,
    NOTE_DS4, NOTE_FS4, NOTE_GS4, NOTE_DS4, NOTE_FS4, NOTE_CS4, NOTE_DS4, NOTE_B3, NOTE_D4, NOTE_DS4, NOTE_D4, NOTE_CS4, NOTE_B3, NOTE_CS4,
    NOTE_D4, NOTE_B3, NOTE_CS4, NOTE_DS4, NOTE_FS4, NOTE_CS4, NOTE_D4, NOTE_CS4, NOTE_B3, NOTE_CS4, NOTE_B3, NOTE_CS4,
    NOTE_FS4, NOTE_GS4, NOTE_D4, NOTE_DS4, NOTE_FS2, NOTE_CS4, NOTE_D4, NOTE_CS4, NOTE_B3, NOTE_B3, NOTE_CS4,
    NOTE_D4, NOTE_D4, NOTE_CS4, NOTE_B3, NOTE_CS4, NOTE_DS4, NOTE_FS4, NOTE_GS4, NOTE_DS4, NOTE_FS4, NOTE_CS4, NOTE_DS4, NOTE_B3, NOTE_CS4, NOTE_B3,
    NOTE_DS4, NOTE_FS4, NOTE_GS4, NOTE_DS4, NOTE_FS4, NOTE_CS4, NOTE_DS4, NOTE_B3, NOTE_D4, NOTE_DS4, NOTE_D4, NOTE_CS4, NOTE_B3, NOTE_CS4,
    NOTE_D4, NOTE_B3, NOTE_CS4, NOTE_DS4, NOTE_FS4, NOTE_CS4, NOTE_D4, NOTE_CS4, NOTE_B3, NOTE_CS4, NOTE_B3, NOTE_B3,
    NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_CS4, NOTE_DS4, NOTE_B3, NOTE_E4, NOTE_DS4, NOTE_E4, NOTE_FS4,
    NOTE_B3, NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_FS3, NOTE_E4, NOTE_DS4, NOTE_CS4, NOTE_B3, NOTE_E3, NOTE_DS3, NOTE_E3, NOTE_FS3,
    NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_B3, NOTE_CS4, NOTE_DS4, NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_FS3,
    NOTE_B3, NOTE_B3, NOTE_AS3, NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_E4, NOTE_DS4, NOTE_E4, NOTE_FS4, NOTE_B3, NOTE_AS3,
    NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_CS4, NOTE_DS4, NOTE_B3, NOTE_E4, NOTE_DS4, NOTE_E4, NOTE_FS4,
    NOTE_B3, NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_FS3, NOTE_E4, NOTE_DS4, NOTE_CS4, NOTE_B3, NOTE_E3, NOTE_DS3, NOTE_E3, NOTE_FS3,
    NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_B3, NOTE_CS4, NOTE_DS4, NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_FS3,
    NOTE_B3, NOTE_B3, NOTE_AS3, NOTE_B3, NOTE_FS3, NOTE_GS3, NOTE_B3, NOTE_E4, NOTE_DS4, NOTE_E4, NOTE_FS4, NOTE_B3, NOTE_CS4,
    };


    const PROGMEM int noteDurations[] = {
    16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
    16, 16, 16, 16, 16, 16, 8, 16, 16, 16, 16, 16, 16, 16, 16,
    8, 8, 16, 16, 16, 16, 16, 16, 8, 8, 8,
    8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
    8, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
    8, 16, 16, 16, 16, 16, 16, 16, 16, 8, 8, 8,
    8, 8, 16, 16, 16, 16, 16, 16, 8, 8, 8,
    8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
    8, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
    8, 16, 16, 16, 16, 16, 16, 16, 16, 8, 8, 8,
    8, 16, 16, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
    8, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
    8, 16, 16, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
    8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 8,
    8, 16, 16, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
    8, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
    8, 16, 16, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
    8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 8,
    8, 8, 16, 16, 16, 16, 16, 16, 8, 8, 8,
    8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
    8, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
    8, 16, 16, 16, 16, 16, 16, 16, 16, 8, 8, 8,
    8, 8, 16, 16, 16, 16, 16, 16, 8, 8, 8,
    8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
    8, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
    8, 16, 16, 16, 16, 16, 16, 16, 16, 8, 8, 8,
    8, 16, 16, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
    8, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
    8, 16, 16, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
    8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 8,
    8, 16, 16, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
    8, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
    8, 16, 16, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
    8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 8,
    };

    void setup() {
    pinMode(LED_R, OUTPUT);
    pinMode(LED_Y, OUTPUT);
    pinMode(LED_G, OUTPUT);
    pinMode(LED_B, OUTPUT);

    }

    void loop() {
    if (checkClick())
    nya();
    digitalWrite(LED_R, LOW);
    digitalWrite(LED_G, LOW);
    digitalWrite(LED_Y, LOW);
    digitalWrite(LED_B, LOW);
    }

    void nya()
    {
    int noteCount = sizeof(melody) / sizeof(int);

    bool toggleLeds = true;

    for (int thisNote = 0; thisNote < noteCount; thisNote++) {
    if (checkClick())
    return;

    digitalWrite(LED_R, toggleLeds);
    digitalWrite(LED_Y, toggleLeds);
    digitalWrite(LED_G, !toggleLeds);
    digitalWrite(LED_B, !toggleLeds);
    toggleLeds = !toggleLeds;

    noTone(BUZZER);

    int noteDuration = 1200 / noteDurations[thisNote];

    int octaveMul = 2;

    tone(BUZZER, octaveMul * melody[thisNote], noteDuration);


    int pauseBetweenNotes = noteDuration * 1.30;
    delay(pauseBetweenNotes);

    }
    }bool checkClick()
    {
    static bool buttonWasUp = true;
    bool result = false;
    bool buttonIsUp = digitalRead(BUTTON);

    if (buttonWasUp && !buttonIsUp) {
    delay(50);
    result = true;
    }
    buttonWasUp = buttonIsUp;
    return result;
    }
     
  10. grigin

    grigin Нуб

    Загрузил 1.80 - Загружает программу, но происходит вот это: https://vk.com/video236381200_456239100
    Что-то чувствую себя совсем гуманитарием, но не вижу в чём проблема?
     
  11. ZAZ-965

    ZAZ-965 Гуру

    Кхе, запамятовал, данные из flash памяти считываем с помощью макроса pgm_read_word_near, т.е. строки обращения к noteDurations и melody будут выглядеть так
    Код (C++):
    //считываем массив из памяти
    int noteDuration = 1200 /  pgm_read_word_near (noteDurations+thisNote);

    tone(BUZZER, octaveMul *  pgm_read_word_near (melody+thisNote), noteDuration);
     
    grigin нравится это.
  12. grigin

    grigin Нуб

    Спасибо, всё заработало! Очень рад!!
     
  13. Dromond

    Dromond Нуб

    Добрый день! пытаюсь повторить. IDE 1.8.12
    Пока подключена к компу все работает, но если юсб просто подключаю к розетке, то нет реакции.
    Что не так, куда копать?
    В диспетчере устройств поставил порт com3 как и в инструментах ide
    Код в приложении
    Скетч использует 8504 байт (29%) памяти устройства. Всего доступно 28672 байт.
    Глобальные переменные используют 178 байт (6%) динамической памяти, оставляя 2382 байт для локальных переменных. Максимум: 2560 байт.
    Перезагрузка платы открытием/закрытием порта COM3 на 1200bps
    PORTS {COM3, } / {} => {}
    PORTS {} / {COM3, } => {COM3, }
    Found upload port: COM3
     

    Вложения:

    • cat.ino
      Размер файла:
      11,5 КБ
      Просмотров:
      276
  14. parovoZZ

    parovoZZ Гуру

    кто она?

    розетка на 230 вольт?
     
  15. Dromond

    Dromond Нуб

    она - типовая плата из набора nyan - arduino Leonardo
    розетка - через обычную зарядку для телефона/порт юсб на ПК без запуска IDE