P ROTOT Y PI N G WITH
ARDUINO
FEDERICO LEONI- DADA- 2015/16
Get started The Arduino is a great platform for learning circuits and micro controller programming. For those who don’t have experience with circuits or micro controllers it can be hard to know where to start. We’ll set up the basics here so that you can get experimenting and learn how much fun can be had with circuits. The first thing we’ll need to do in order to get things moving is to install the Arduino IDE. This software is where you’ll write all of the code that will control the micro controller and the attached circuit components. You can download the IDE at the official Arduino Download Page. Once downloaded you’ll need to unzip the folder into a convenient location. Then run the Arduino.EXE file. Once you’ve done that, you should see the above window.
1
2
Arduino Basics – Controlling the LED In this post, I’ll walk you through one of the more basic things you can do with your Arduino Uno – lighting up the LED on the Arduino board. We will see how you can program the Arduino to control the rate of flashing of this LED, or any other LED. We will also learn how to tell the Arduino which GPIO pins to use to send output signals, and how to control the length of time the output signals are sent. You should first have the Arduino software installed on your computer before you begin. http://www.circuitbasics.com/arduino-basics-controlling-led/:
3
What is an LED? A light-emitting diode (LED) is a two-lead semiconductor light source. It is a p–n junction diode, which emits light when activated.[4] When a suitable voltage is applied to the leads, electrons are able to recombine with electron holes within the device, releasing energy in the form of photons. This effect is called electroluminescence, and the color of the light (corresponding to the energy of the photon) is determined by the energy band gap of the semiconductor.
4
SAY HELLO TO THE SOLDERLESS BREADBOARD! Solderless breadboards are an important tool in your quest for electronics mastery. They allow you to make quick circuits, test out ideas before making a more permanent Printed Circuit Board. They’re also inexpensive and reusable.. You can pick on up at any hobby shop or electronics supply store. They often look like this (image above). Basically, a chunk of plastic with a bunch of holes. However, something special is going on inside the breadboard! Although you can’t see it, inside the breadboard are many strips of metal that connect the rows and columns together. The metal strips are springy so that when you poke a wire into the hole, the clips grab onto it.
5
In the images above you can see how there are two kinds of metal strips. There are short ones that connect 5 row holes at a time, and then there are very long ones that connect 25 (or more!) column holes at a time. The long columns are called rails and the short strips are called rows. Breadboards are almost always made so that they have two sets of 5-hole rows and on either side there are a pair of rails. For example the breadboard on the left has 30 row pairs and 2 sets of double rails on either side. The one on the right is quite small, it has only 17 row pairs and no rails. In this lesson, we will show pictures of both the tiny breadboard on a protoshield and also using a ‘standard’ breadboard without a shield. However, after this lesson, you’ll be more on your own to figure out how to connect up the standard breadboard, OK?
6
RESISTORS The resistor is the most basic and also most common electronic part. An electronic gadget, such as an mp3 player has easily a thousand resistors inside of it! Resistors have one job to do, and that is to resist the flow of electricity (otherwise known as current). That’s why they’re called resistors. By resisting current they control where and how fast it flows. One common way of thinking about this is if we were talking about water current, then pipes are like resistors. Thin pipes let less water through (high resistance), thick pipes let a lot of water through (low resistance). Wth a fire hydrant, you want low resistance. With a water fountain, you’d want high resistance. If you mixed up the two pipe sizes, you wouldnt be able to put out a fire and you’d hurt yourself while trying to get a drink.
6
Resistance is measured in ohms, often written as the symbol Ω. The bigger the resistance value (in ohms) the more it fights. Most resistors you’ll see range between 1 ohm and 1 megaohm (1.0 MΩ). Since the resistive element is inside a ceramic casing, its not possible to tell the resistance of a resistor just by looking at it. You’ll have to read it by looking at the colored stripes on the body of the resistor. This is known as the resistor color code, and its a real pain when you first start electronics. Eventually you’ll get really good at telling the value of a resistor just by glance but to start off you’ll want to use a reference chart. (Or you can use a multimeter to measure the resistance accurately) Click here to view a reference chart that you can print out (in color) and use as your guide. There are also website calculators that you may find very handy Remember: Just because the stripes are in a certain order doesn’t mean the resistor has a direction! Resistors are the same forward and backwards, it doesnt matter which way they are used.
7
SENSORS The most fun you can have (after blinking LEDs) is using sensors to detect whats going on in the world and act on that information. However, all sensors have their own methods of interfacing. That can make them a real pain to work with: some need pull-up resistors, some need certain power supplies, some use lots of power, some don’t. Since there aren’t that many different sensors that people tend to want to use I have collected the most common sensors with code examples and wiring diagrams. Force sensitive resistor - Used to detect physical pressure such as pinching, squeezing, pushing, brushing Photocells - Used to detect light/dark, breakbeams, simple object detection Temperature - Used to determine environmental temperature Tilt sensors - Used to detect motion/vibration and orientation. PIR sensors - Used to detect motion activity such as animals or people Thermocouple - Used for temperature measurements, usually those above 150°C IR receivers - Used to detect IR signals from remote controls
8
9
ARDUINO UNO: PHOTOCELL - SENSING LIGHT In this tutorial, we will send the analog readings obtained from a Photo Resistor, also known as a Light Dependent Resistor (LDR), to the computer. We will display the each reading on the monitor using a simple Processing sketch. Here is what you will need to complete the Arduino side of the project: Parts Required: PhotoCell (or PhotoResistor) 10K resistor Breadboard Arduino UNO 3-4 wires(to connect it all together) USB cable to upload sketch and for Serial communication with Processing..
10
The scketch: Serial.begin(9600) : starts the serial communication between the Arduino and Processing lightLevel=analogRead(photoRPin) : take a reading from the analog pin 0. minLight and maxLight: automatically adjust the minimum and maximum range of the sensor adjustedLightLevel: used to map the reading from the PhotoCell to a value between 0-100. The adjustment of the light level is not necessary, and could be handled in Processing instead. The delay(50) at the end of the sketch, is only used to slow down the transmission of the Serial messages to Processing. Depending on what you want to do with the sensor data, you may wish to increase or decrease the amount of delay.
11
PIR SENSOR TUTORIAL In this tutorial we will connect our HC-SR501 PIR (movement) Sensor to an Arduino UNO. The PIR sensor will be powered by the Arduino and when movement is detected, the PIR sensor will send a signal to Digital Pin 2. The Arduino will respond to this signal by illuminating the LED attached to Pin 13. PIR Sensor (Part 1) : Showed that this sensor can be used in isolation (without an Arduino). However, I will still demonstrate how you can attach this sensor to the Arduino so that we can move forward to more advanced objectives and concepts.
12
https://youtu.be/JrSduQNGv-w
13
THE ANNOYING CUBE
14
THE CUBE PROTOTYPE In this project we have been asked to Design a 10 x 10 Cm Cube that can react at human presence, such movement, touch, heat. My aim is create an useless but annoying cube, a box that react at movement trought a PIR sensor, playing the LO LO LO song trought a recording board anytime somebody will pass close at the cube.
15
THE CODE:
This code it aloud the PIR sensor to send a signal at the recording board playing the LOLOLO song each time the sensor get activated to movement.
16
17
18
19
THE FINAL PROTOTYPE
Here a video the final prototype in action, thanks for watching! https://vimeo.com/164434296
20
FEDERICO LEONI EDINBURGH NAPIER UNIVERSITY YEAR 3 DADA COURSE - 2015/16
21