## Topic outline

• ### General

Lights

I will edit this tomorrow, Bernadette.

• ### Topic 1

 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

## 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 : GenesisThe 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 Youtube : The nature of light

## Simple circuit theory

 Voltage, current, resistance Youtube : Basics of electric charge Youtube : Current and potential 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. Youtube : Ohms law Ohms law

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

## Lights and arduino

 LEDs come in many colours. But you can get one lED in all colours! Here is the Sparkfun Inventors Guide. The experiment you want is number 12. Sparkfun Circ-12

## Lights and Arduino

 x a b

c

## 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 weber250498 */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. /* 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); }}

## Light sensing LEDs

 LDR Serial monitor