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!


Sunday, February 11, 2018

Lab 16: Ultrasonic Rangefinder and other Sensors

In this lab, we worked with the ultrasonic rangefinder and continued to program the VEX robot in preparation for our final lab.  A lot of this lab consisted of reading the provided information and learning how the ultrasonic rangefinder can help us complete our final lab challenge.  At the end of the lab, there were two mini challenges to complete.  The first mini challenge required us to write a program that causes the robot to turn away from obstacles in front of it.



You can see that when the robot is right next to an object in front of it, the ultrasonic rangefinder recognizes this and the robot turns.



The second challenge required us to write a program for the VEX robot which made the robot turn in circles until it located an object in front of it.  We used a pink lunch bag as the object.  The VEX then spun in circles until the ultrasonic rangefinder located the lunch bag.  Once the lunch bag was located, the VEX then moved forward until right next to the bag, then the robot stopped.  This was practice for stopping in front of the burning candle and preparing to blow out the flame for our final lab challenge.



The VEX instantly located the lunch bag and quickly moved towards it, then stopped just short.  This movement was a direct result of our programming.  Parameters can always be adjusted by modifying the code to the VEX.



Lab 16 finished!

Lab 15: Building Square bot and doing the Electrical Tape Maze with and without Encoders

In this lab, we constructed the VEX robot.  The manual is available online at:
http://www.bit.ly/vexmanual .  We constructed the VEX robot according to the instructions except that we also added encoders for the left and right side of the robot.  The only thing we had to change out from the instructions were the 3" front square axels.  Those were switched with 4.5" square axels which were slightly longer to accommodate the encoder.



Here you can see we are assembling the VEX robot.



Once the VEX robot was assembled, we downloaded a program to the robot which would allow us to control it using a remote control.



Here you can see that I am controlling the VEX robot by using the remote control.  This exercise was only for practice and future movements by the VEX will be controlled using programming.



The next step was to write code that made the robot go where we wanted it to go.   There was a small course setup in the hallway with electrical tape that we navigated.  After a few trials of understanding the distances and numbers relating to the encoders, we were able to successfully navigate the course.



This video is one of our trial attempts that we used to determine travel distances and their relation to the encoders.  We only needed to make a few adjustments before we successfully completed the course without touching the course boundaries.


Lab 15 finished!

Lab 13: Building Sensors For Your Robot

In this lab, we focused on making sensors for our VEX robots.  We first constructed a flame sensor circuit and tested the phototransistor with a candle.  Once the circuit was completed, we used the flame of the candle to get sensor readings.



You can see that as she brings the candle closer to the phototransistor, the sensor readings on the serial monitor are changing.  The phototransistor is working properly and this quick exercise confirmed it.



We then constructed our own flame sensor by soldering the phototransistor to a resistor and lead wires.  Once the soldering was completed, we inserted heat shrink tubing over the connections and shrunk them to protect the connections from shorting out.  This flame sensor will be attached to our VEX robot and used to detect the candle flame in the maze which we hope to extinguish by then turning on fans that will blow out the candle.



Lab 13 finished!

Lab 12: Distance Sensing With Ultrasonic Sensor and Arduino

In this lab we used the ultrasonic sensor in combination with the Arduino to obtain sensor readings from the ultrasonic sensor.  Once connected per the lab instructions, we then opened the serial monitor to observe what the sensor readings were.


You can see the values changing as her hand moves closer and farther away from the ultrasonic sensor.  The sensor is detecting her hand and the distance it is from the sensor, then displaying those sensor readings in the serial monitor.


We then added a motor to the circuit and adjusted the program so that if there was something in front of the ultrasonic sensor less than a predetermined distance, the motor would then be turned on.



You can see that when her hand is placed close to the ultrasonic sensor, the sensor reading then becomes within the predetermined distance and the motor is turned on by the Arduino.  These sensor values can be adjusted to whatever distance you like.


Lab 12 finished!

Lab 11: Microcrontrollers, Input and Output

In this lab, we looked at microcontrollers and how they work.  Microcontrollers are like small computers that can take input such as sound, light, movement or a switch and convert it to operating a motor, turning on a light or emitting a sound from a speaker.  They can also be programmed to react however the user wishes by simply adjusting the code.


We entered a code that would flash and LED 8 times, then stop.  This was done with a "for" statement that said as long as the LED hasn't flashed 8 times, flash with a 200ms delay.  Once the LED had flashed 8 times, the loop ended and the flashing stopped.



We also programmed the arduino to turn or off a pin connected to an LED based on when a switch was pushed.  This made it so we could turn the light on and off with the switch, just like a typical light switch, except this one was programmed with a microcontroller.



You can see the LED light up as the switch is pushed.


Another part of the lab concerned if statements and comparison operators (==, !=, <, >).  We can tell the arduino that "if" some condition is met, then perform a certain operation.  If/else can also be useful in that the program can check to see if the "if" statement is true, and when the statement isn't true, the "else" part of the program will be performed.


LDR (Light Dependent Resistors) are resistors that change their resistance based on the amount of light hitting the sensor.  We put the LDR into the circuit we still had from the previous exercise.  We then entered the code into the program that would switch between turning 2 LED's on based on the amount of light hitting the LDR.


Here you can see we are using the light from a phone to increase or decrease the amount of light hitting the LDR, which then will turn on or off the LED's based on the sensor value of the LDR.



Next we used a thermistor to control a motor.  We used the same circuit from the previous experiment and just switched the LDR with the thermistor.  We also added a TIP120 transistor to the circuit to control the motor.



As the thermistor is covered by her hands, the temperature goes up and shuts off the motor.  Then as she releases the thermistor, it cools off and the motor turns back on.  The control of the motor is done by the preset sensor range in the program.



The last part of the lab we connected a motion detector to the Arduino as an analog input.  We also connected a relay to the circuit so that when the motion sensor detected movement, the relay would switch.



You can hear the clicking of the relay as my hand is placed in front of the motion sensor, which is the black spherical looking component on the breadboard.



Lab 11 finished!

Tuesday, February 6, 2018

CODE.ORG Homework Assignment

This work was done online on the site CODE.ORG.  As practice for our future lab where we have to code the VEX robots, we did some practice coding on the code.org website.  There were three different parts to the coding exercises: Star Wars, Minecraft and Elsa from Frozen.



In this video, you can see that I entered code with those colored blocks.  The coding lesson was simplified by making each command a drag and drop block.  Actual coding is more complicated but for our learning purposes, simpler is better.  I chose the characters, music, points added or subtracted.




In this video, you can see that the scene froze and would not play after clicking the "Run" button.  I added exploding barrels through code but when they exploded, it froze the program.  You can see the barrels frozen in mid explosion.  However, the video is still good to look at because you can see the code blocks I added to make the scene.  I added things like how far to walk, when to turn, what to do if there's lava ahead.



Here you can see I had a chance to practice with Elsa.  The code I added on the right made her create the snowflake shape on the ice.  You can see that I directed her by telling her how far to skate, when to turn, how far to turn, and how many times to repeat the same movements.



Here you can see that I chose my own blocks of code to add to the coding and this was the shape she skated out.  I didn't know ahead of time exactly what the shape would be but it turned out pretty cool in my opinion.



Overall, I'm glad we had this practice of coding because we will soon be putting this knowledge to the test when we program our own VEX robots in a similar manner.



CODE.ORG Homework Assignment finished!

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 ...