January 17, 2019
I have two separate sensors (clap and obstacle detection) in this while loop. When I hash out the lines associated with one, the other runs as expected, and vice versa. So they both run individually, but together Edison will only detect the obstacle and then run both (motor) outputs separately with the clapping output first.
I suspect it's a need to have them in separate sections of code (but which would come first? An example would be awesome as I'm not getting anywhere), or perhaps it's just not possible to achieve.
Context: I'm trying to build a lego train project where monitoring and detecting a clap will trigger the RH motor connected to a track junction switch, and monitoring to detect the train going past will trigger the LH motor to lower a level crossing boom.
Kind thanks! The code: http://www.edpyapp.com/share/xkQV6
March 16, 2018
It is important to note with the Edison robot that if the robot is driving. The robot can detect that as a clap since the Edison is making noise.
So to make sure that is not the reason you are getting errors. I advise that you add a slight delay to detecting a clap after a drive then clear the data.
January 17, 2019
Thanks for your reminder about the motors triggering a clap-detection. I've taken this into account with all my subsequent attempts. Here is the latest unsuccessful one: http://www.edpyapp.com/share/xZGxe
No matter what I try, an obstacle is commonly triggering the 'Ed.DriveRightMotor' action - which is the one the clap is supposed to trigger, and indeed does.
Occasionally it does work and the left motor is triggered, but then without restarting the program it reverts to the problem above. Sometimes it seems to be working better than other times.
The main things in the code I'm varying are: adding the commands to reset the sensors (both clap and obstacle detection); adding wait times; also varying the ways the while loop is constructed. However, no matter how many times and places I add waits and sensor resets, or vary the while loop structure, after many hours of careful experimenting I haven't identified any logical pattern.
Are you sure there isn't something fundamentally wrong with the way I'm trying to do this?
Thanks so much for your insights and time.