Topic outline

  • General

    Lights

    I will edit this tomorrow, Bernadette.


  • Topic 1

    Heads up

    1
    2
    3

    5050

    • Need a roll of 5050 analogue rgb LED strip lighting
    • 3 x mofset
    • 12 volt 2 amp power supply
    • Arduino
    • leads
    5
    6
    7
    8
    9
    • Topic 2

      Why study light

      The very first chapter of the bible talks about light. As modern Physics attests, before there was anything else in the universe, there was light.

      The study of lights in the sky gave rise to the first science of Astronomy. It allowed ancient people to predict the coming of the seasons and hence, when the animals they hunted would return and the plants the depended on would start to bloom.

      The scientific method is based on light. The scientific method first was applied by Isaac Newton observing light and gave rise to the time of science called the enlightenment, a word based on light and a time of great scientific advancement.


      Modern quantum mechanics, the structure of the atom, was based calculations of light.


      And the biggest scientific endeavour, the SKA, is about observing the light in the universe.

      First book of the bible : Genesis


      The SKA

      Light has properties that can be measured

        • colour (wave length)
        • speed
        • direction
        • frequency
        • polarity
        We can use an Arduino to measure all these.

        Movie BBC : Let there be light

        • Topic 3

          Simple circuit theory

          Voltage, current, resistance

          This is a bit echy. 

          Electrical resisitance can be thought of as the ability of a circuit to oppose current flow.

          The more Voltage applied the more a circuit can resist.

          Hence, the the resistance of a circuit is defined as the ration between the voltage divided by the current.

          ohms law

          Ohms law

          • Topic 4

            LEDs and light

            A LED or light emitting diode is an electronic device that emitts light when the correct  voltage is applied to it.

            It is polar in that current only flows one way accross the diode, inside the plastic cap. The longer leg (anode) connects to the + side of a battery.

            led

            LED in a circuit

            When a LED is in a circuit, it it always in series with a resistor. This protects it from burning out.

            To work out the value of the resistor use Ohms Law. Divide the voltage ot he power supply with the suggested current rating from the data sheet.

            An Arduino has an output of 5v direct so 5/16 mA = 330 ohms approx.

            Use a 330 ohm resistor.

            LED tutorial

            Data sheet

            led circuit

            • Topic 5

              Lights and arduino

              LEDs come in many colours. But you can get one lED in all colours!

              rgb led

              Here is the Sparkfun Inventors Guide. The experiment you want is number 12.

              Sparkfun Circ-12
              • Topic 6

                5050 light strip

                This is so cool. You can program a strip of LEDs to change colour (provided you get the right ones).

                Use the Adafruit link to figure out the wiring and get example code.

                http://learn.adafruit.com/rgb-led-strips/overview

                Tips

                The arduino can take 12 volts

                A mofset is a kind of transisior so it has inout, output and ground.

                Each segment has 3 LEDs one red, one blue and one green

                Pay attention to the amps required. remember each LED takes about 0.02 amps so 30 LEDs require about 30*0.02*3 or about 2 amps.

                LED strips

                // color swirl! connect an RGB LED to the PWM pins as indicated
                // in the #defines
                // public domain, enjoy!

                #define REDPIN 5
                #define GREENPIN 6
                #define BLUEPIN 3

                #define FADESPEED 100 // make this higher to slow down

                void setup() {
                pinMode(REDPIN, OUTPUT);
                pinMode(GREENPIN, OUTPUT);
                pinMode(BLUEPIN, OUTPUT);
                }


                void loop() {
                int r, g, b;

                // fade from blue to violet
                for (r = 0; r < 256; r++) {
                analogWrite(REDPIN, r);
                delay(FADESPEED);
                }
                // fade from violet to red
                for (b = 255; b > 0; b--) {
                analogWrite(BLUEPIN, b);
                delay(FADESPEED);
                }
                // fade from red to yellow
                for (g = 0; g < 256; g++) {
                analogWrite(GREENPIN, g);
                delay(FADESPEED);
                }
                // fade from yellow to green
                for (r = 255; r > 0; r--) {
                analogWrite(REDPIN, r);
                delay(FADESPEED);
                }
                // fade from green to teal
                for (b = 0; b < 256; b++) {
                analogWrite(BLUEPIN, b);
                delay(FADESPEED);
                }
                // fade from teal to blue
                for (g = 255; g > 0; g--) {
                analogWrite(GREENPIN, g);
                delay(FADESPEED);
                }
                }

                Assignment

                Can you now hack the code to change the time it takes to change colour.

                Can you have just one colour?

                Can you mix the rgb to get any colour you want?

                • Topic 8

                  Lights and Arduino

                  blink
                  chasers
                  http://instructables.com/id/Create-a-Shard-Light/
                  • Topic 9

                    Lights and Arduino

                    x
                    a
                    b

                    c

                    • Topic 10

                      Hacking the code : Sparkfun circuit #04 : multiple leds

                      This is the introduction to a whole world of projects, from a simple chaser like this prac or 16x16 matrices to all sorts of applications.

                      Look elsewhere on the sight for ideas.

                      Some students like to use an Arduino called a lilypad to make clothes that sparkle.

                      /* old logo project

                      here is an oldie but a goodie

                      set up an array of LEDs and turn them on and off

                      author m weber
                      250498

                      */
                      int ledPin1 = 13;
                      int ledPin2 = 12;
                      int ledPin3 = 11;
                      int ledPin4 = 10;
                      int ledPin5 = 9;
                      int ledPin6 = 8;
                      int ledPin7 = 7;
                      int ledPin8 = 6;
                      int ledPin9 = 5;
                      int ledPin10 = 4;

                      void setup()
                      {
                      pinMode(ledPin1,OUTPUT);
                      pinMode(ledPin2,OUTPUT);
                      pinMode(ledPin3,OUTPUT);
                      pinMode(ledPin4,OUTPUT);
                      pinMode(ledPin5,OUTPUT);
                      pinMode(ledPin6,OUTPUT);
                      pinMode(ledPin7,OUTPUT);
                      pinMode(ledPin8,OUTPUT);
                      pinMode(ledPin9,OUTPUT);
                      pinMode(ledPin10,OUTPUT);

                      }

                      void loop()
                      {
                      digitalWrite(ledPin1, HIGH);
                      delay (134);
                      digitalWrite(ledPin1,LOW);
                      delay(145);
                      digitalWrite(ledPin2, HIGH);
                      delay (134);
                      digitalWrite(ledPin2,LOW);
                      delay(145);
                      digitalWrite(ledPin3, HIGH);
                      delay (134);
                      digitalWrite(ledPin3,LOW);
                      delay(145);
                      digitalWrite(ledPin4, HIGH);
                      delay (134);
                      digitalWrite(ledPin4,LOW);
                      delay(145);
                      digitalWrite(ledPin5, HIGH);
                      delay (134);
                      digitalWrite(ledPin5,LOW);
                      delay(145);
                      digitalWrite(ledPin6, HIGH);
                      delay (134);
                      digitalWrite(ledPin6,LOW);
                      delay(145);
                      digitalWrite(ledPin7, HIGH);
                      delay (134);
                      digitalWrite(ledPin7,LOW);
                      delay(145);
                      digitalWrite(ledPin8, HIGH);
                      delay (134);
                      digitalWrite(ledPin8,LOW);
                      delay(145);
                      digitalWrite(ledPin9, HIGH);
                      delay (134);
                      digitalWrite(ledPin9,LOW);
                      delay(145);
                      digitalWrite(ledPin10, HIGH);
                      delay (134);
                      digitalWrite(ledPin10,LOW);
                      delay(145);

                      }

                      This is clearly an inefficient way to write code

                      There is an opportunity to define the integers an an array. the setup as a loop and main void loop as a loop as well

                      Further refinements include defining the number in the delay() function as a variable, so it can be changed easily.

                      (Could use the find and replace function as well)

                      There is also a chip called a multiplexor

                      which takes in a series of values then outputs them as a parallel output.

                      The whole seis 0f 8 LEDs then can be programmed by one line in and 8 lines out.

                      Sparkfun SIK has details. 

                      /* You could just use arrays and loops

                      author mrweber

                      230216

                      */


                      int ledPin[] = {3,4,5,6,7,8,9,10,11,12}; // create an array for output pins

                      void setup() {
                      for (int index=0; index<10; index++)  // use an array to initialise output pins
                      {                                                 // array starts at 0, 0 - 9 is 10 elements
                      pinMode(ledPin [index],OUTPUT);
                      }
                      }

                      void loop() {
                      for (int index=0; index<9; index++) // use a FOR loop to assign a value to elements
                      {
                      digitalWrite(ledPin[index],HIGH);  // blinks from l => r
                      delay(500);
                      digitalWrite(ledPin[index],LOW);
                      }
                      for (int index=9; index>0; index--)  // blinks from r => l
                      {
                      digitalWrite(ledPin[index],HIGH);
                      delay(500);
                      digitalWrite(ledPin[index],LOW);
                      }
                      }

                      • Topic 16

                        Light sensing LEDs

                        LDR
                        Serial monitor
                        • Topic 18

                          Spectroscope

                          • Topic 19

                            x

                            • Topic 20

                              x