About the code structure

Hi everyone, I am using raspberry pi pico. I was using micropython and circuitpython but there was a problem with them so I decided to use arduino ide.
I want to use 2 RFID, 2 stepper , 2 load cell and 2 relay module same time. For example if two tag has been read from 2 RFID reader module, steppers need to work same time.

I was using like this :

await asyncio.gather(data_task0, data_task1)

With this code, I was doing multitasking. data_task0 and data_task1 is:

data=uart.read() #RFID is here
if data!= None:
      measureweight()
      runstepper()
      time.sleep(1)
      stopstepper()
      relay.high()
      time.sleep(1)
      relay.low()
      postdata #posting data to internet with ethernet module

So my question is, can I do all this things with millis() or should I need to find a way RTOS ? ( I am not expert of coding, today I am trying to make this with millis() but I couldn't do yet :smiley: )

You should be able to do it with millis I think. Read up about state machines - you may want two of them, one doing a single RFID, stepper and relay and the other for the second set.

Hello neveregret
Keep it simple and stupid.

Run some tutorials to the hardware selected.
If you are happy with the results of the tutorials you can merge these to the project by using control structures.
Have a nice day and enjoy coding in C++.
Дайте миру шанс!

Thank you, I will look state machines.

thank you.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.