How to trigger software where Sensor changes value


#1

Hi Everyone,

I’m trying to figure out if it’s possible to “listen” to several sensors in this way: when a sensor measures a different value, I would like to trigger a function on the Orion where this sensor is connected.

Does anyone know how to do this?

Thank you in advance,

Diego


#2

Hello,

I used a PIR sensor to detect someone; ( it was my dog the first time) and the led display " seen!" ; and the Mbot spinning around.( with a Mcore Mbot, not an orion but it is obviously easy/ the same with an orion.)

I hope it helps

J-M


#3

Hi J-M,

how did you code this trigger? Are you looping for a change of value? Did you use an external trigger as provided with Arduino?

Can you show me the piece of code?

Thank you so much in advance,

Diego


#4

Diego-

Are you working in mBlock or writing code in the Arduino IDE?

There are many loop structures that will accomplish this. In all of them, you’ll need the establish the sensors first, take and save some form of inital reading (either a single value or over a small interval). Then you can build any number of loops while checking the current sensor value against the saved one.

While this specific block is part of the Arduino IDE, the concept can be implemented in Scratch/mBlock as well.

https://www.arduino.cc/en/Reference/DoWhile

–andrew


#5

Hi Diego,

very sorry for my late answer… here’s a piece of code : the message is Vu! in the French thenit gets cleared; ( seen )

almost of ( short) kind of msg are possible!


#6