Sunday, February 11, 2018

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!

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