Skip to main content
5 votes
Accepted

Is it bad practice to multitask without timing constraints

Like often, the answer is: It depends. Generally it is non-blocking programming, when you do only short things on each loop. What exactly can be considered short depends on the situation, meaning, ...
chrisl's user avatar
  • 16.5k
5 votes

What’s the most common (and low cost) microprocessor with at least two threads?

ESP32. Dual core 240MHz, plus an extra XLP state machine. Cheap and easily available on eBay/Amazon/Ali Express etc. And with full Arduino support.
Majenko's user avatar
  • 106k
4 votes
Accepted

Is my sketch 'thread safe'?

There is indeed a race condition in your code: if an interrupt fires while you are reading one of the counters, you might read garbage. If it fires between reading and resetting the counter, you loose ...
Edgar Bonet's user avatar
  • 44.3k
3 votes

How can I create multiple running threads?

You could also give my ThreadHandler library a try https://bitbucket.org/adamb3_14/threadhandler/src/master/ It uses an interrupting scheduler to allow context switching without relaying on yield() ...
Adam Bäckström's user avatar
2 votes

How can I create multiple running threads?

And here is yet another microprocessor cooperative multitasking library – PQRST: a Priority Queue for Running Simple Tasks. Home page Class-level documentation Repository, with downloads and issues ...
Norman Gray's user avatar
2 votes

Multi-threaded Robot

You could also give my ThreadHandler library a try https://bitbucket.org/adamb3_14/threadhandler/src/master/ It uses an interrupting scheduler to allow context switching without relaying on yield() ...
Adam Bäckström's user avatar
2 votes

Is it bad practice to multitask without timing constraints

If you are running off battery, then you should consider having the microcontroller sleep as much as possible, and not poll the sensors more often than needed. AFAIK, the Arduino core library provides ...
Edgar Bonet's user avatar
  • 44.3k
1 vote

How can I make my code Thread-Safe?

I am not sure this is related to thread-safety, but you should be aware that strip.show() is a slow function that blocks while the data is being sent. setPixelColor(), in contrast, is fast, as it only ...
Edgar Bonet's user avatar
  • 44.3k
1 vote
Accepted

arduino acclerometer with servo motor

Here's the final form of my project. I've added motor detach function since it still shivers a bit. #include <SoftwareSerial.h> #include <Servo.h> const int MPU_addr=0x68; // MPU-6050 ...
John Cho's user avatar
1 vote

arduino acclerometer with servo motor

I think you want something like Blink Without Delay, but with more tasks. Here is my interpretation of your description which extends Blink Without Delay by adding three more tasks to: read the ...
tim's user avatar
  • 699
1 vote
Accepted

Arduino stuck in PT_WAIT_UNTIL

By best attempt to provide something of an answer. You have said: PT_WAIT_UNTIL(pt, millis() - lastTimeBlink > 1000); That is not literally represented in your code, so I take your question to ...
timemage's user avatar
  • 5,414
1 vote

Why I can't exit this while loop by reading from the Serial?

The problem is that you check inside the two functions Sparkle and GreenYellow for another serial byte. Then when it's unequal, you move back to the while loop where you wait for the next serial byte, ...
Michel Keijzers's user avatar
1 vote

How can I use both ultrasonic and IR sensor and ultrasonic sensor at ones with Arduino

While it is completely possible to hook two or more sensors to Arduino, once you talk about multithreading, you need to think about RTOS support. You can achieve parallel processing by creating 2 ...
Prasan Dutt's user avatar
1 vote

ESP32: How to run two independent PID controllers, one per core?

esp32_technical_reference_manual_en.pdf Page 620 As mentioned before, only an elevated process with PID of 0/1 can initiate a process switch. The new process may have any PID from 0 ~ 7 after the ...
Norm T's user avatar
  • 21
1 vote

Can we call GPRS HTTP request asynchronously in Arduino?

Sure there is. All you're doing is reading and writing serial data. All you have to do is learn how to do that without blocking. Most code I see bandied around is of the form: Send AT command Delay ...
Majenko's user avatar
  • 106k
1 vote

Protothread Library Stalling on One Thread

In protothreadCollectAndTransmitData you have a timestamp variable that never gets updated: static int protothreadCollectAndTransmitData(struct pt* pt, int interval) { static unsigned long ...
001's user avatar
  • 963
1 vote

Multiple independent LED patterns

I know the post is old, but I checked the example with the array based approach and in my opinion: sizeof(led_timing[i])/sizeof(led_timing[i][0]) will always yield the allocated size (number of ...
TommyL's user avatar
  • 11

Only top scored, non community-wiki answers of a minimum length are eligible