Your SlideShare is downloading. ×
0
Asssociation of Science Education Annual Conference                      , 3rd January 2013Arduino for the classroom     D...
Previous experiences: Contemporary Sciences and Research                            ASE2013 Dr.Pérez               2      ...
ASE2013 Dr.Pérez   3
http://www.youtube.com/watch?v=O1MvwAw_MHk                ASE2013 Dr.Pérez             4
http://www.youtube.com/watch?v=FbuvE1n18ZE               ASE2013 Dr.Pérez              5
My experience with students (Technology branch):Course 2011-2012Year 11: 16-17 years old4h per weekNumber of students: 12C...
Student blogs 2011-2012 (Catalan language and part inEnglish)http://cricardoromani.wordpress.comhttp://cdanielaparicio.wor...
ASE2013 Dr.Pérez   8
ASE2013 Dr.Pérez   9
WHY PROGRAMMING?•   Computer science is no more about    computers than astronomy is about    telescopes. Edsger Dijkstra•...
TINKERINGASE2013 Dr.Pérez         11
Tinkering, the “MacGyver” styleFrom the “Tinkering” exhibition at the Exploratorium,San Francisco:“Tinkering is what happe...
This definition says a lot about the Arduino way ofprototyping. Actually there is not a manual on how todo things but a re...
THE HACKER ATTITUDE FOR OUR STUDENTS               ASE2013 Dr.Pérez    14
The Hacker Attitude for our studentsFive things taken from Eric S. Raymond’sHow To Become a Hacker:1. The world is full of...
What is Arduino• Open Source Hardware, you can make your  own board, or buy one.• Cheap, easily available.• Open Source So...
ESPLORA          LEONARDO                     ASE2013 Dr.Pérez   17
Arduino Uno    ASE2013 Dr.Pérez   18
Arduino Language•   C like syntax, but simplified•   Abstracts the pin naming to numbers•   Trades efficience for ease of ...
Download Arduino software at       www.arduino.cc               ConsoleASE2013 Dr.Pérez               20
BOARD TYPEASE2013 Dr.Pérez          21
Sketch name or version              Toolbar       Save       Open     New  UploadVerify                                   ...
Comments                   about the                   code                   Setup code                   Define         ...
/*BlinkTurns on an LED on for one second,then off for one second, repeatedly. Blink code is the equivalentThis example cod...
ASE2013 Dr.Pérez   25
ARDUINO AND A DC MOTOR                              Arduino UnoDC motor           Transistor IRF530           Resistor    ...
SOURCE CODE FOR ARDUINO MOTORconst int transistorPin = 9; // connected to transistor gatevoid setup() {pinMode(transistorP...
MOTOR TO IRRADIATE A SURFACE VERY SLOWLY                   ASE2013 Dr.Pérez        28
ASE2013 Dr.Pérez   29
http://www.youtube.com/watch?v=UQEtOJE02wE              ASE2013 Dr.Pérez               30
http://www.youtube.com/watch?v=e1iUjelHC6w                  ASE2013 Dr.Pérez           31
RGB LED BLINKING                   ASE2013 Dr.Pérez   32
Controlling LEDs cubes: Explosion exampleint Columns[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};int Rows[] = {12, 11, 10};int t=400;v...
for(int i=0;i<t;i++){  if(i%2==0){                                  digitalWrite(Rows[0], HIGH);    digitalWrite(Rows[0], ...
ASE2013 Dr.Pérez   35
ASE2013 Dr.Pérez   36
http://www.youtube.com/watch?v=z4Qo9NDDRco                       ASE2013 Dr.Pérez      37
Materials for      LDR and LED-RGB using Arduino●   -4 resistor 220 Ω●   -1 LDR sensor●   -1 RGB LED●   -1 potenciometer● ...
LDR      ASE2013 Dr.Pérez   39
Pulse width modulation             ASE2013 Dr.Pérez   40
ASE2013 Dr.Pérez   41
Microcontroller ATMega328               Brain               Sight         Hearing                                 Sensors ...
Analog to digital conversion                                 Analog sensor 0 to 5V                                Sampling...
ASE2013 Dr.Pérez   44
ASE2013 Dr.Pérez   45
SOURCE CODE: RGB-LED colour change depending on light levelint valueLDR = 1; /*First we define the variable name as intege...
void loop() {     The “void” in the header is what the function will return (or spit out)                  when it happens...
else if((valueLDR >= 895) & (valueLDR < 959)){   else if((valueLDR >= 639) & (valueLDR < 703)){else if((valueLDR >= 383) &...
else if((valueLDR >= 127) & (valueLDR < 191)) else{                                                {digitalWrite(ledRed, 1...
http://www.youtube.com/watch?v=hxkYNy4zTWc                          ASE2013 Dr.Pérez   50
ASE2013 Dr.Pérez   51
Playing music with Arduinohttp://www.youtube.com/watch?v=YDL9WIVfS9w                          ASE2013 Dr.Pérez   52
ASE2013 Dr.Pérez   53
ASE2013 Dr.Pérez   54
Spychip technology?                      ASE2013 Dr.Pérez   55
ASE2013 Dr.Pérez   56
ASE2013 Dr.Pérez   57
SENSORS FOR                   ARDUINOASE2013 Dr.Pérez           58
Transistor: to amplify the signal of thesensor to the Arduino                 ASE2013 Dr.Pérez          59
Sensors with 1kOhm resistor an NPN amplifier transistorand a 7805 regulator transitor and sensors from SandboxElectronics,...
LED RGB AS AN EMITTER AND         NORMAL LED AS A SENSOR           AND PROGRAM THE           BRUNTON ALGORITHM TO         ...
Cloud internet of things platforms: www.cosm.comVisualize and store sensor data online www.nimbits.com                    ...
ASE2013 Dr.Pérez   63
ASE2013 Dr.Pérez   64
http://www.virtualbreadboard.net                    ASE2013 Dr.Pérez   65
Approximate pricing• Arduino Leonardo             €25• Resistors, LEDs, LDR         around €5• Breadboard                 ...
Resources•   www.arduino.cc•   http://blocs.xtec.cat/mecanica•   www.sparkfun.com•   www.fritzing.org•   www.buildinginter...
ACKNOWLEGMENTSThis project on Arduino for the classroom is part of a project entitled«Contemporary Sciences and Research» ...
Upcoming SlideShare
Loading in...5
×

Arduino2013

2,060

Published on

Annual Conference Association Science Education 2013
Arduino for the classroom

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
2,060
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
86
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Arduino2013"

  1. 1. Asssociation of Science Education Annual Conference , 3rd January 2013Arduino for the classroom Dr. Francisco Pérez García Institut Pompeu Fabra ASE2013 Dr.Pérez 1
  2. 2. Previous experiences: Contemporary Sciences and Research ASE2013 Dr.Pérez 2 http://www.youtube.com/watch?v=F_xkHOpMA9s
  3. 3. ASE2013 Dr.Pérez 3
  4. 4. http://www.youtube.com/watch?v=O1MvwAw_MHk ASE2013 Dr.Pérez 4
  5. 5. http://www.youtube.com/watch?v=FbuvE1n18ZE ASE2013 Dr.Pérez 5
  6. 6. My experience with students (Technology branch):Course 2011-2012Year 11: 16-17 years old4h per weekNumber of students: 12Course 2012-2013 (Set 2012-Dec 2012)Year 11: 16-17 years old4h per weekNumber of students: 16(Also 2 students of year 12: 17-18 years old in their compulsoryRESEARCH PROJECT) First term: programming with C Second term: simple projects with Arduino and preparing project Third term: original project with ArduinoAt Institut Pompeu Fabra (High School in Martorell near Barcelona, ASE2013 Dr.Pérez 6Catalonia)
  7. 7. Student blogs 2011-2012 (Catalan language and part inEnglish)http://cricardoromani.wordpress.comhttp://cdanielaparicio.wordpress.comhttp://cjordinieto.wordpress.comhttp://cjosepalemany.wordpress.comhttp://cadrianarrebola.wordpress.comhttp://calexdelrincon.wordpress.comhttp://ccristiansegovia.wordpress.comStudent blogs 2012-2013 (Only in English language)http://candreamasegosa.wordpress.comhttp://ckelianpordoy.wordpress.comhttp://civanroldan.wordpress.comhttp://cadriansanchez.wordpress.comhttp://cvictorsalvador.wordpress.comhttp://ccarlesdelaiglesia.wordpress.com ASE2013 Dr.Pérez 7
  8. 8. ASE2013 Dr.Pérez 8
  9. 9. ASE2013 Dr.Pérez 9
  10. 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
  11. 11. TINKERINGASE2013 Dr.Pérez 11
  12. 12. Tinkering, the “MacGyver” styleFrom the “Tinkering” exhibition at the Exploratorium,San Francisco:“Tinkering is what happens when you try something youdon’t quite know how to do, guided by whim, imagination,and curiosity.When you tinker, there are no instructions - but thereare also no failures, no right or wrong ways of doingthings. It’s about figuring out how things work andreworking them.Contraptions, machines, wildly mismatched objectsworking in harmony - This the stuff of tinkering.” ASE2013 Dr.Pérez 12
  13. 13. This definition says a lot about the Arduino way ofprototyping. Actually there is not a manual on how todo things but a reference collection of samples thatpeople can modify and combine with other examplesto learn about the logic of the programme and theboard.It’s a “hands on” way of working in which even junkbecomes a source for learning and buildingprototypes.The reuse of material from other fields is an other bigknowledge and material source. Learning how to dothings by looking how other things work and can behacked.Circuit bending and patching are two key words in thislearning school. ASE2013 Dr.Pérez 13
  14. 14. THE HACKER ATTITUDE FOR OUR STUDENTS ASE2013 Dr.Pérez 14
  15. 15. The Hacker Attitude for our studentsFive things taken from Eric S. Raymond’sHow To Become a Hacker:1. The world is full of fascinating problemswaiting to be solved.2. No problem should ever have to be solvedtwice.3. Boredom and drudgery are evil.4. Freedom is good.5. Attitude is no substitute for competence. ASE2013 Dr.Pérez 15
  16. 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
  17. 17. ESPLORA LEONARDO ASE2013 Dr.Pérez 17
  18. 18. Arduino Uno ASE2013 Dr.Pérez 18
  19. 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
  20. 20. Download Arduino software at www.arduino.cc ConsoleASE2013 Dr.Pérez 20
  21. 21. BOARD TYPEASE2013 Dr.Pérez 21
  22. 22. Sketch name or version Toolbar Save Open New UploadVerify Code ASE2013 Dr.Pérez 22
  23. 23. Comments about the code Setup code Define variables Loop code Main codeASE2013 Dr.Pérez 23
  24. 24. /*BlinkTurns on an LED on for one second,then off for one second, repeatedly. Blink code is the equivalentThis example code is based on exampleto a Hello world to testcode that is in the public domain.*/const int LED = 13; /* LED connected our Arduino boardto digital pin 13*/void setup() {// initialize the digital pin as an output./*Pin 13 has an LED connected on mostArduino boards: */pinMode(LED, OUTPUT);}void loop() {digitalWrite(LED, HIGH); // set the LED ondelay(1000); // wait for a seconddigitalWrite(LED, LOW); // set the LED offdelay(1000); // wait for a second} ASE2013 Dr.Pérez 24
  25. 25. ASE2013 Dr.Pérez 25
  26. 26. ARDUINO AND A DC MOTOR Arduino UnoDC motor Transistor IRF530 Resistor AND THIS Diode 1N4001 SOURCE CODE ASE2013 Dr.Pérez 26
  27. 27. SOURCE CODE FOR ARDUINO MOTORconst int transistorPin = 9; // connected to transistor gatevoid setup() {pinMode(transistorPin, OUTPUT);}void loop(){ // loop= repeat again and againdigitalWrite(transistorPin, HIGH); // switch the motor ondelay(50); // wait for 50 milisecondsdigitalWrite(transistorPin, LOW); // switch the motor offdelay(5000); // wait for 5 seconds} ASE2013 Dr.Pérez 27
  28. 28. MOTOR TO IRRADIATE A SURFACE VERY SLOWLY ASE2013 Dr.Pérez 28
  29. 29. ASE2013 Dr.Pérez 29
  30. 30. http://www.youtube.com/watch?v=UQEtOJE02wE ASE2013 Dr.Pérez 30
  31. 31. http://www.youtube.com/watch?v=e1iUjelHC6w ASE2013 Dr.Pérez 31
  32. 32. RGB LED BLINKING ASE2013 Dr.Pérez 32
  33. 33. Controlling LEDs cubes: Explosion exampleint Columns[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};int Rows[] = {12, 11, 10};int t=400;void setup() /*For loop: if this conditional is true do the code inside{ the curly brackets, if it’s false exists the for loop*/int counter;for (int counter = 0; counter < 10; counter++){pinMode(Columns[counter], OUTPUT); }for (int counter = 0; counter < 4; counter++){pinMode(Rows[counter], OUTPUT); }}void loop(){digitalWrite(Rows[1], HIGH);digitalWrite(Columns[4], HIGH);delay(t); ASE2013 Dr.Pérez 33
  34. 34. for(int i=0;i<t;i++){ if(i%2==0){ digitalWrite(Rows[0], HIGH); digitalWrite(Rows[0], LOW); digitalWrite(Rows[2], HIGH); digitalWrite(Rows[2], LOW); digitalWrite(Columns[1], HIGH); digitalWrite(Columns[1], HIGH); digitalWrite(Columns[3], HIGH); digitalWrite(Columns[3], HIGH); digitalWrite(Columns[5], HIGH); digitalWrite(Columns[5], HIGH); digitalWrite(Columns[7], HIGH); } digitalWrite(Columns[7], HIGH); else { } digitalWrite(Rows[0], LOW); else { digitalWrite(Rows[2], LOW); digitalWrite(Columns[1], LOW); digitalWrite(Columns[0], HIGH); digitalWrite(Columns[3], LOW); digitalWrite(Columns[2], HIGH); digitalWrite(Columns[5], LOW); digitalWrite(Columns[8], HIGH); digitalWrite(Columns[7], LOW); digitalWrite(Columns[6], HIGH); digitalWrite(Rows[0], HIGH); } digitalWrite(Rows[2], HIGH); delay(1); } } delay(1); digitalWrite(Rows[0], HIGH);} digitalWrite(Rows[2], HIGH); for(int j=0; j<t; j++){ delay(t); if(j%2==0){ for (int counter = 0; counter < 10; counter++){ digitalWrite(Columns[0], LOW); digitalWrite(Columns[counter], LOW); } digitalWrite(Columns[2], LOW); for (int counter = 0; counter < 4; counter++){ digitalWrite(Columns[8], LOW); digitalWrite(Rows[counter], LOW); } digitalWrite(Columns[6], LOW); ASE2013 Dr.Pérez 34 }
  35. 35. ASE2013 Dr.Pérez 35
  36. 36. ASE2013 Dr.Pérez 36
  37. 37. http://www.youtube.com/watch?v=z4Qo9NDDRco ASE2013 Dr.Pérez 37
  38. 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
  39. 39. LDR ASE2013 Dr.Pérez 39
  40. 40. Pulse width modulation ASE2013 Dr.Pérez 40
  41. 41. ASE2013 Dr.Pérez 41
  42. 42. Microcontroller ATMega328 Brain Sight Hearing Sensors Smell (analog inputs) Taste TouchNerves Wires, Circuit Muscles Actuators (analog Heart outputs) ASE2013 Dr.Pérez 42
  43. 43. Analog to digital conversion Analog sensor 0 to 5V Sampling at Nyquist rate Value of each sample transformed to binary format ASE2013 Dr.Pérez 43
  44. 44. ASE2013 Dr.Pérez 44
  45. 45. ASE2013 Dr.Pérez 45
  46. 46. SOURCE CODE: RGB-LED colour change depending on light levelint 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 othersint ledBlue=11;int pinLDR = 1;//3 outputs for each RGB colour: red, green and blue /*The setup function comes before the loop function, and everythingvoid setup(){ happens inside the curly backets*/pinMode(ledRed, OUTPUT); /*Outputs are declared in setup, this is done bypinMode(ledGreen, OUTPUT); usingthe pinMode function, in this particular example we declare numbers 9, 10 and 11 aspinMode(ledBlue, OUTPUT); OUTPUT (in capital letters)*/analogReference(EXTERNAL); ASE2013 Dr.Pérez 46}
  47. 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 voidvalueLDR = 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}
  48. 48. else if((valueLDR >= 895) & (valueLDR < 959)){ else if((valueLDR >= 639) & (valueLDR < 703)){else if((valueLDR >= 383) & (valueLDR < 447)){digitalWrite(ledRed, 255); digitalWrite(ledRed, 128); digitalWrite(ledRed, 0);digitalWrite(ledGreen, 128); digitalWrite(ledGreen, 128); digitalWrite(ledGreen, 128);digitalWrite(ledBlue, 0);} digitalWrite(ledBlue, 255);} digitalWrite(ledBlue, 0);}else if((valueLDR >= 831) & (valueLDR < 895)){ else if((valueLDR >= 575) & (valueLDR < 639)){else if((valueLDR >= 319) & (valueLDR < 383)){digitalWrite(ledRed, 255); digitalWrite(ledRed, 0); digitalWrite(ledRed, 0);digitalWrite(ledGreen, 255); digitalWrite(ledGreen, 128); digitalWrite(ledGreen, 255);digitalWrite(ledBlue, 0);} digitalWrite(ledBlue, 255);} digitalWrite(ledBlue, 0);}else if((valueLDR >= 767) & (valueLDR < 831)){ else if((valueLDR >= 511) & (valueLDR < 575)){else if((valueLDR >= 255) & (valueLDR < 319)){digitalWrite(ledRed, 255); digitalWrite(ledRed, 0); digitalWrite(ledRed, 128);digitalWrite(ledGreen, 255); digitalWrite(ledGreen, 0); digitalWrite(ledGreen, 255);digitalWrite(ledBlue, 128);} digitalWrite(ledBlue, 255);} digitalWrite(ledBlue, 0);}else if((valueLDR >= 703) & (valueLDR < 767)){ else if((valueLDR >= 447) & (valueLDR < 511)){else if((valueLDR >= 191) & (valueLDR < 255)){digitalWrite(ledRed, 128); digitalWrite(ledRed, 0); digitalWrite(ledRed, 0);digitalWrite(ledGreen, 255); digitalWrite(ledGreen, 0); digitalWrite(ledGreen, 255);digitalWrite(ledBlue, 255); digitalWrite(ledBlue, 128); digitalWrite(ledBlue, 128); ASE2013 Dr.Pérez 48} } }
  49. 49. else if((valueLDR >= 127) & (valueLDR < 191)) else{ {digitalWrite(ledRed, 128); digitalWrite(ledRed, 0);digitalWrite(ledGreen, 255); digitalWrite(ledGreen, 0);digitalWrite(ledBlue, 128);} digitalWrite(ledBlue, 0);else if((valueLDR >= 63) & (valueLDR < 127)) }{ }digitalWrite(ledRed, 128); void color(int red, int green, int blue)digitalWrite(ledGreen, 128); {digitalWrite(ledBlue, 128);} analogWrite(ledRed, 255-red);else if((valueLDR >=0) & (valueLDR < 63)){ analogWrite(ledGreen, 255-green);digitalWrite(ledRed, 55); analogWrite(ledBlue, 255-blue);digitalWrite(ledGreen, 55); // PWM for every colourdigitalWrite(ledBlue, 55); } ASE2013 Dr.Pérez 49
  50. 50. http://www.youtube.com/watch?v=hxkYNy4zTWc ASE2013 Dr.Pérez 50
  51. 51. ASE2013 Dr.Pérez 51
  52. 52. Playing music with Arduinohttp://www.youtube.com/watch?v=YDL9WIVfS9w ASE2013 Dr.Pérez 52
  53. 53. ASE2013 Dr.Pérez 53
  54. 54. ASE2013 Dr.Pérez 54
  55. 55. Spychip technology? ASE2013 Dr.Pérez 55
  56. 56. ASE2013 Dr.Pérez 56
  57. 57. ASE2013 Dr.Pérez 57
  58. 58. SENSORS FOR ARDUINOASE2013 Dr.Pérez 58
  59. 59. Transistor: to amplify the signal of thesensor to the Arduino ASE2013 Dr.Pérez 59
  60. 60. Sensors with 1kOhm resistor an NPN amplifier transistorand a 7805 regulator transitor and sensors from SandboxElectronics, battery, LCD and Arduino Uno board ASE2013 Dr.Pérez 60
  61. 61. LED RGB AS AN EMITTER AND NORMAL LED AS A SENSOR AND PROGRAM THE BRUNTON ALGORITHM TO TRANSFORM RGB EMISSION TO WAVELENGTH 350-700uASE2013 Dr.Pérez 61
  62. 62. Cloud internet of things platforms: www.cosm.comVisualize and store sensor data online www.nimbits.com ASE2013 Dr.Pérez www.thingspeak.com 62
  63. 63. ASE2013 Dr.Pérez 63
  64. 64. ASE2013 Dr.Pérez 64
  65. 65. http://www.virtualbreadboard.net ASE2013 Dr.Pérez 65
  66. 66. Approximate pricing• Arduino Leonardo €25• Resistors, LEDs, LDR around €5• Breadboard €10• MQ sensors (CO, CH4, etc) €5 each• MG811 (CO2 sensor) €50• Voice recognition shield €60• Arduino for Android €50Sometimes very high import taxes from China! ASE2013 Dr.Pérez 66
  67. 67. Resources• www.arduino.cc• http://blocs.xtec.cat/mecanica• www.sparkfun.com• www.fritzing.org• www.buildinginternetofthings.com• www.atmel.com/avr• www.avrfreaks.net• www.mcselec.com• www.argentdata.com ASE2013 Dr.Pérez 67
  68. 68. ACKNOWLEGMENTSThis project on Arduino for the classroom is part of a project entitled«Contemporary Sciences and Research» given to Institut Pompeu Fabrafrom 2012 to 2014 and includes a book edition on ContemporarySciencesMore information on Arduino and videos http://blocs.xtec.cat/mecanicaMore information on the whole project at http://blocs.xtec.cat/pileBook available on Nature magazine discoveries in 2012 supported bythis project at http://www.formaciovirtual.com/cs ASE2013 Dr.Pérez 68
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×