Sunday, February 18, 2018

Lab 17: Using IR Sensors for flame and line detection for the VEX

In this lab, we used everything we learned in the previous labs to complete this final lab challenge.  The challenge was to navigate a maze with predetermined dimensions using only the code we created.  Not only did we need to navigate the maze successfully but we also needed to locate a light source.  The light source we used was a cluster of infrared LED's attached to a breadboard and power source.  Since we were required to put out the flame of a candle, we placed a piece of paper on top of the infrared LED's to simulate the candle flame and a successful extinguishing of the "flame" would be turning on our VEX robot fans and knocking the piece of paper off the breadboard.


We first started by writing our code for the VEX.  Since we had used functions in previous labs, the first step was to create our functions in the code.  This would allow us to write specific code for movements in a simpler manner than having to write out the entire section.  Here is the first parts of our code and you can see the functions we used.




You can see that the functions we created were functions to move straight, turn right, turn left and move back.  They were all listed before the main task so we could refer to them when writing our commands for the VEX.



For the first part of the main task of the code, we had the VEX travel down the left hand hallway towards room #2.  For each room we had two parts: the VEX would turn and "look" into the room, then either enter the room after finding the light source or move on to the next room.  If there was no light source, the VEX would turn and continue searching.  Once the VEX picked up on the light source in a room, the code for extinguishing the flame took over.







You can see that for each room the VEX comes across, it either sees the light source and enters the room or moves on to the next room.  Since our light source was a cluster of infrared LED's, the light was able to bounce off the walls and be seen by the flame sensor on the VEX.  The VEX didn't even need to enter the room to find the light source, just facing the opening was good enough to register an increase in the flame sensor value.


Once our code had been tested, adjusted and retested many times, it was time to perform the challenge.  We only wrote one code for all 3 challenges since that one code would search the entire maze and find the light source no matter which room the light source was in.  Here is our VEX robot in action finding and extinguishing the light sources like a boss!



The VEX robot was able to successfully navigate the maze and complete all 3 challenges with the highest average time.  This was due in large part to the extra time we spent as a group refining the code and testing the path of the VEX!


Lab 17 finished!


No comments:

Post a Comment

Lab 17: Using IR Sensors for flame and line detection for the VEX

In this lab, we used everything we learned in the previous labs to complete this final lab challenge.  The challenge was to navigate a maze ...