Multi loop error

Hello All,

I am facing error when i run below code. in this code i use scheduler, I run 2 loops, in the first loop blinking RGB LED and in the second loop just print some name. if RGB LED blinking code not used, both loop run but when i used LED code, program not upload and error occur.

// Include Scheduler since we want to manage multiple tasks.
#include <Scheduler.h>
#include <FastLED.h>
#define LED_PIN     10
#define NUM_LEDS    1
CRGB leds[NUM_LEDS];
//int led2 = 12;
//int led3 = 11;

void setup() {
  Serial.begin(9600);

 FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);

  // Add "loop2" and "loop3" to scheduling.
  // "loop" is always started by default.
Scheduler.startLoop(loop2);
}

// Task no.1: blink LED with 1 second delay.
void loop() {
  Serial.print("hiii");
  leds[0] = CRGB(255, 0, 0);
  FastLED.show();
  delay(500);  
  leds[0] = CRGB(0, 255, 0);
  FastLED.show();
  delay(500);
  leds[0] = CRGB(0, 0, 255);
  FastLED.show();
  delay(500);
}

void loop2(){
    Serial.print("Simtest");

}

I am facing error when i run below code

Please post the full error message and details of which Arduino board you are using

UKHeliBob:
Please post the full error message and details of which Arduino board you are using

"Error- Couldn't find a Board on the selected port. Check that you have the correct port selected. If it is correct, try pressing the board's reset button after initiating the upload." This error occurs only when I used scheduler with LED blinking. if i run 2 void loops without LED code it works properly.

I have used Adafruit Feather M0 adalogger board

Maybe there is a conflict between FastLED and Scheduler libraries. You might want to try other schedulers, such as FreeRTOS for example

Hi,
Have you got Adafruit Feather M0 adalogger board selected as your hardware?
Have you tried to upload and run a simple "Blink" code?

Tom... :slight_smile:

TomGeorge:
Hi,
Have you got Adafruit Feather M0 adalogger board selected as your hardware?
Have you tried to upload and run a simple "Blink" code?

Tom... :slight_smile:

yes sir i am already testing simple blink test with a simple LED .

lesept:
Maybe there is a conflict between FastLED and Scheduler libraries. You might want to try other schedulers, such as FreeRTOS for example

Sir
After adding FreeRTOS library my program not compile error- Arduino: 1.8.9 (Windows 7), Board: “Adafruit Feather M0”

Build options changed, rebuilding all
In file included from C:\Users\Simtestdynamics\Documents\Arduino\libraries\FreeRTOS\src/Arduino_FreeRTOS.h:62:0,

from C:\Users\Simtestdynamics\Desktop\sketch_aug09b\sketch_aug09b.ino:1:

C:\Users\Simtestdynamics\Documents\Arduino\libraries\FreeRTOS\src/portable.h:93:21: fatal error: avr/wdt.h: No such file or directory

#include <avr/wdt.h>

^

compilation terminated.

exit status 1
Error compiling for board Adafruit Feather M0.

“I am also Include avr.wdt in my code”

lesept:
Maybe there is a conflict between FastLED and Scheduler libraries. You might want to try other schedulers, such as FreeRTOS for example

conflict problem resolved. Thank you, Sir, for your help.

I have used another multitasking library in my code.

OK, sorry but I think this FreeRTOS library can’t be used with your board.
I was going to suggest to use this one (TaskScheduler) : which on did you choose?

lesept:
OK, sorry but I think this FreeRTOS library can’t be used with your board.
I was going to suggest to use this one (TaskScheduler) : which on did you choose?

Thank You very much, sir. You give me an idea related to my problem, even i don’t know its error due to library conflict.

sir, Now i am looking for controlling delay time using exe.

for changing delay I don’t want each time I open my sketch. simply i want user configurable delay time.

I am not clear why you needed to use a scheduler in the first place

amitshishodia:
for changing delay I don't want each time I open my sketch. simply i want user configurable delay time.

Do you mean the value 500 in delay(500) ?
Well you need some sort of memory to store it.

But a more simple way would be to use a potentiometer (it's a kind of memory :slight_smile: ). You read the voltage value and assign the duration according to this value.

// Read analog value from potentiometer middle pin
int value=analogRead(potPin)
// Map analog values 0-1024 to delay (here between 0 and 2000 ms)
int duration= map(value, 0, 1023, 0, 2000);
delay (duration);

Whenever the board is switched off and switched on again, if the potentiometer didn't move, the duration value should remain the same (or roughly the same). And it's user configurable.

lesept:
Whenever the board is switched off and switched on again, if the potentiometer didn't move, the duration value should remain the same (or roughly the same). And it's user-configurable.

Sir its good idea, but i make one device for vibration measurement in this device I cant use a potentiometer. i just want to connect my device to my computer with the help of some exe(app/software) change delay time without open Arduino ide. and again disconnected the device from the computer. and start acquiring data from new delay time.

So if you don't want a serial connexion, use bluetooth (HC-06)

And make an app on your smartphone that keeps the last value used (store it in a file) using appinventor. You can find tutorials on the web.