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.
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.
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.
Lab 11 finished!
No comments:
Post a Comment