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, ...
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.
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 ...
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() ...
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 ...
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() ...
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 ...
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 ...
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 ...
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 ...
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 ...
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, ...
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 ...
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 ...
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 ...
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 ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
threads × 30arduino-uno × 10
programming × 6
interrupt × 4
sensors × 3
bluetooth × 3
library × 3
arduino-mega × 2
led × 2
esp32 × 2
timers × 2
serial × 1
esp8266 × 1
arduino-ide × 1
c++ × 1
servo × 1
communication × 1
shields × 1
analogread × 1
ethernet × 1
sketch × 1
web-server × 1
rgb-led × 1
accelerometer × 1
http × 1