social pharmacy d-pharm 1st year by Pragati K. Mahajan
Arduino2013
1. Asssociation of Science Education Annual Conference
, 3rd January 2013
Arduino for the classroom
Dr. Francisco Pérez García
Institut Pompeu Fabra
ASE2013 Dr.Pérez 1
6. My experience with students (Technology branch):
Course 2011-2012
Year 11: 16-17 years old
4h per week
Number of students: 12
Course 2012-2013 (Set 2012-Dec 2012)
Year 11: 16-17 years old
4h per week
Number of students: 16
(Also 2 students of year 12: 17-18 years old in their compulsory
RESEARCH PROJECT)
First term: programming with C
Second term: simple projects with Arduino and preparing project
Third term: original project with Arduino
At Institut Pompeu Fabra (High School in Martorell near Barcelona,
ASE2013 Dr.Pérez 6
Catalonia)
7. Student blogs 2011-2012 (Catalan language and part in
English)
http://cricardoromani.wordpress.com
http://cdanielaparicio.wordpress.com
http://cjordinieto.wordpress.com
http://cjosepalemany.wordpress.com
http://cadrianarrebola.wordpress.com
http://calexdelrincon.wordpress.com
http://ccristiansegovia.wordpress.com
Student blogs 2012-2013 (Only in English language)
http://candreamasegosa.wordpress.com
http://ckelianpordoy.wordpress.com
http://civanroldan.wordpress.com
http://cadriansanchez.wordpress.com
http://cvictorsalvador.wordpress.com
http://ccarlesdelaiglesia.wordpress.com
ASE2013 Dr.Pérez 7
10. WHY PROGRAMMING?
• Computer science is no more about
computers than astronomy is about
telescopes. Edsger Dijkstra
• The computer revolution hasn’t happened
yet. Allan Kay
• Debugging is the essence of intellectual
activity. Seymour Pappert
ASE2013 Dr.Pérez 10
12. Tinkering, the “MacGyver” style
From the “Tinkering” exhibition at the Exploratorium,
San Francisco:
“Tinkering is what happens when you try something you
don’t quite know how to do, guided by whim, imagination,
and curiosity.
When you tinker, there are no instructions - but there
are also no failures, no right or wrong ways of doing
things. It’s about figuring out how things work and
reworking them.
Contraptions, machines, wildly mismatched objects
working in harmony - This the stuff of tinkering.”
ASE2013 Dr.Pérez 12
13. This definition says a lot about the Arduino way of
prototyping. Actually there is not a manual on how to
do things but a reference collection of samples that
people can modify and combine with other examples
to learn about the logic of the programme and the
board.
It’s a “hands on” way of working in which even junk
becomes a source for learning and building
prototypes.
The reuse of material from other fields is an other big
knowledge and material source. Learning how to do
things by looking how other things work and can be
hacked.
Circuit bending and patching are two key words in this
learning school.
ASE2013 Dr.Pérez 13
15. The Hacker Attitude for our students
Five things taken from Eric S. Raymond’s
How To Become a Hacker:
1. The world is full of fascinating problems
waiting to be solved.
2. No problem should ever have to be solved
twice.
3. Boredom and drudgery are evil.
4. Freedom is good.
5. Attitude is no substitute for competence.
ASE2013 Dr.Pérez 15
16. What is Arduino
• Open Source Hardware, you can make your
own board, or buy one.
• Cheap, easily available.
• Open Source Software.
• Very widespread, many projects openly
available.
• Extra HW (shields) available (over 250 at
http://shieldlist.com.
ASE2013 Dr.Pérez 16
19. Arduino Language
• C like syntax, but simplified
• Abstracts the pin naming to numbers
• Trades efficience for ease of use
• Easy to learn, yet powerful
• Lots of example code
• Easy to reuse C-code from other projects
• Libraries can be written in C++
• Lots of libraries available
ASE2013 Dr.Pérez 19
22. Sketch name or version
Toolbar
Save
Open
New
Upload
Verify Code
ASE2013 Dr.Pérez 22
23. Comments
about the
code
Setup code
Define
variables
Loop code
Main
code
ASE2013 Dr.Pérez 23
24. /*Blink
Turns on an LED on for one second,
then off for one second, repeatedly. Blink code is the equivalent
This example code is based on exampleto a Hello world to test
code that is in the public domain.*/
const int LED = 13; /* LED connected our Arduino board
to digital pin 13*/
void setup() {
// initialize the digital pin as an output.
/*Pin 13 has an LED connected on most
Arduino boards: */
pinMode(LED, OUTPUT);
}
void loop() {
digitalWrite(LED, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(LED, LOW); // set the LED off
delay(1000); // wait for a second
}
ASE2013 Dr.Pérez 24
26. ARDUINO AND A DC MOTOR
Arduino Uno
DC motor
Transistor IRF530
Resistor AND THIS
Diode 1N4001 SOURCE CODE
ASE2013 Dr.Pérez 26
27. SOURCE CODE FOR ARDUINO MOTOR
const int transistorPin = 9; // connected to transistor gate
void setup() {
pinMode(transistorPin, OUTPUT);
}
void loop()
{ // loop= repeat again and again
digitalWrite(transistorPin, HIGH); // switch the motor on
delay(50); // wait for 50 miliseconds
digitalWrite(transistorPin, LOW); // switch the motor off
delay(5000); // wait for 5 seconds
}
ASE2013 Dr.Pérez 27
38. Materials for
LDR and LED-RGB using Arduino
● -4 resistor 220 Ω
● -1 LDR sensor
● -1 RGB LED
● -1 potenciometer
● -1 Arduino Uno
● - Wire
● - Breadboard
● - USB wire AB type or microUSB for Arduino Leonardo
ASE2013 Dr.Pérez 38
46. SOURCE CODE: RGB-LED colour change depending on light level
int valueLDR = 1; /*First we define the variable name as integer and it is assigned
a value*/
int ledRed = 9;
int ledGreen=10; // or /*Comment*/ can be anywhere, do not affect code, help others
int ledBlue=11;
int pinLDR = 1;
//3 outputs for each RGB colour: red, green and blue
/*The setup function comes before the loop function, and everything
void setup(){
happens inside the curly backets*/
pinMode(ledRed, OUTPUT);
/*Outputs are declared in setup, this is done by
pinMode(ledGreen, OUTPUT); usingthe pinMode function, in this particular
example we declare numbers 9, 10 and 11 as
pinMode(ledBlue, OUTPUT); OUTPUT (in capital letters)*/
analogReference(EXTERNAL);
ASE2013 Dr.Pérez 46
}
47. void loop() { The “void” in the header is what the function will return (or spit out)
when it happens, in this case it returns nothing so it is void
valueLDR = analogRead(pinLDR);
if(valueLDR >= 1023){
digitalWrite(ledRed, 128);
digitalWrite(ledGreen, 0);
digitalWrite(ledBlue, 0);
// digitalWrite to obtain different colours
}
else if((valueLDR >= 959) & (valueLDR < 1023)){
digitalWrite(ledRed, 255);
digitalWrite(ledGreen, 0);
digitalWrite(ledBlue, 0);
ASE2013 Dr.Pérez 47
}
60. Sensors with 1kOhm resistor an NPN amplifier transistor
and a 7805 regulator transitor and sensors from Sandbox
Electronics, battery, LCD and Arduino Uno board
ASE2013 Dr.Pérez 60
61. LED RGB AS AN EMITTER AND
NORMAL LED AS A SENSOR
AND PROGRAM THE
BRUNTON ALGORITHM TO
TRANSFORM RGB EMISSION
TO WAVELENGTH 350-700u
ASE2013 Dr.Pérez 61
62. Cloud internet of things platforms: www.cosm.com
Visualize and store sensor data online www.nimbits.com
ASE2013 Dr.Pérez
www.thingspeak.com
62
68. ACKNOWLEGMENTS
This project on Arduino for the classroom is part of a project entitled
«Contemporary Sciences and Research» given to Institut Pompeu Fabra
from 2012 to 2014 and includes a book edition on Contemporary
Sciences
More information on Arduino and videos http://blocs.xtec.cat/mecanica
More information on the whole project at http://blocs.xtec.cat/pile
Book available on Nature magazine discoveries in 2012 supported by
this project at http://www.formaciovirtual.com/cs
ASE2013 Dr.Pérez 68