Tuesday, 1 March 2016

Arduino Part 1

Friday February 25th, 2016
We learned how to make circuits out of an Arduino micro controller, LEDs, resistors and a potentiometer using a breadboard.  We used these connections and Arduino codes to turn LED lights on and off as well as create patterns with them both with a delay function on the code and without it using a potentiometer.


Blink:

First, we used the "Blink Practice" code from the example codes on the program to turn on one LED connected to Pin 13 for a number of milliseconds and off for a number of milliseconds. When we got to 10 milliseconds, the LED appeared to be on continuously because it was blinking too fast for our eyes to see.

Below are some pictures of the codes we used to vary the blink rate.



Some notes that helped us in making the circuit.


Here, we used a 1 kilo Ohm resistor to control the current flow through the LED. And we used the 5 V pin for power supply. The code we wrote turned the "switch" on or off. Therefore, we used a digital system to operate the LED. 


Later, we wrote a code for three LEDs connected to pins 11, 12, and 13 and played with the delay() values to create patterns.



This code, for example gave us a pattern shown in the following video.


We learned that we can create so many more interesting patterns by just varying the delay time.

Using a potentiomenter to change LED behavior:
Then, we introduced a potentiometer to our circuit to control the amount of resistance in the system and therefore the voltage across the LEDs. The potentiomenter is an analogue system that can increase or decrease the voltage across LEDs continuously.

 


We used the following code to introduce the potentiometers (connected to Pin 12) to the code as an integer and control one of the LEDs with the potentiometer.

















We used the next code to control all three LEDs with the potentiometer. Here, the potentiometer controls the rate of blinks while the code controls the pattern, or the order in which the LEDs blink.


In this code, we named the LEDs differently so that the pattern is the same for two of them and different for the other. Keeping this pattern the same, we can increase or decreases the potentiometer value to vary rate.

The product of this arrangement is shown in the following video.



A slightly different code, with Pin_LED defined as one rather than 3 different variables/integers gave as a simpler patter with all three LEDs going on and off at the same time.



No comments:

Post a Comment