Build cool
stuff with
Arduino
William Hooi
Wendell Wong
Centre for Research & Applied Learning in
Sciences
Science Centre ...
What are microcontrollers?
•
•
•
•

Really small computers
With limited hardware resources
Programmable
Can be used to do ...
Doing good for humanity
Fukushima nuclear
disaster

DIY radiation detector built by Tokyo
Hackerspace, connected live to t...
Arduino as an Interative Device
Terminology
• Pins
– A leg on a microcontroller with some specific
function (e.g. Power pin, ground pin, digital input
pin...
Using the breadboard
Horizontal tracks
for power

vertical tracks for
components
Connecting circuit
Program structure
Arduino use a
language similar to
C++

void setup( )
{
}

void loop( )
{
}
Where to start
Determine your
input
Output device:
Determine your
output and device
Input device:
Choose a device

Lightde...
Reading from serial monitor

Verify

Upload

Serial monitor
Activity 1: Blink an LED
longer leg

330
Activity 1: Blink an LED
Assign pin 13 as LED pin

Assign LED pin as output

Turn LED pin on
Wait for 0.5s
Turn Led pin of...
Recap

pinMode (pin number, OUTPUT/INPUT);
digitalWrite(pin number, HIGH/LOW);
delay(milliseconds);
Activity 2: ..and beep a buzzer

Piezo
buzzer
330
Activity 2: ..and beep a buzzer
Assign pin 8 as tone pin

Play a tone on tone pin with 200 Hz and 250ms

Play a tone on to...
Use arrays for longer tunes
Challenge
Build a circuit and write the Arduino
sketch that will enable you to blink 4
LEDs intermittently & play a musica...
Controlling RGB
Activity 4: Light sensing

adafruit.com
Activity 4: Display light reading – Serial
Controlling servo motor
Activity 5: Controlling servo motor

GND

pin 0

+5V
Control servo with trimmer pot
#include <Servo.h>
Recap

#include <Servo.h>
Servo myservo;

myservo.attach (pin number);
myservo.write (angle);
Reading from serial monitor
#include <Servo.h>

create a servo object called ‘myservo’

Start serial comm at 9600bps

Assi...
Replace pot with light sensor
10k
10k
Ideas for projects
Thank you
facebook.com/CRADLEsci
Upcoming SlideShare
Loading in …5
×

Build cool stuff with arduino for sci camp 16 dec13

867 views
533 views

Published on

Slides for Arduino workshop for Science Camp 2013

Published in: Business, Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
867
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
17
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Build cool stuff with arduino for sci camp 16 dec13

  1. 1. Build cool stuff with Arduino William Hooi Wendell Wong Centre for Research & Applied Learning in Sciences Science Centre Singapore Introductory Workshop 13 Dec 2013 facebook.com/CRADLEsci
  2. 2. What are microcontrollers? • • • • Really small computers With limited hardware resources Programmable Can be used to do anything imaginable
  3. 3. Doing good for humanity Fukushima nuclear disaster DIY radiation detector built by Tokyo Hackerspace, connected live to the Internet
  4. 4. Arduino as an Interative Device
  5. 5. Terminology • Pins – A leg on a microcontroller with some specific function (e.g. Power pin, ground pin, digital input pin, analog output pin) Digital pins Arduino has 13 digital pins that can be used as input or output Arduino has 6 analog pins that can only be used as input Analog pins
  6. 6. Using the breadboard Horizontal tracks for power vertical tracks for components
  7. 7. Connecting circuit
  8. 8. Program structure Arduino use a language similar to C++ void setup( ) { } void loop( ) { }
  9. 9. Where to start Determine your input Output device: Determine your output and device Input device: Choose a device Lightdependent resistor (LDR) Light emitting diode (LED) Piezo buzzer
  10. 10. Reading from serial monitor Verify Upload Serial monitor
  11. 11. Activity 1: Blink an LED longer leg 330
  12. 12. Activity 1: Blink an LED Assign pin 13 as LED pin Assign LED pin as output Turn LED pin on Wait for 0.5s Turn Led pin off Wait for 0.5s
  13. 13. Recap pinMode (pin number, OUTPUT/INPUT); digitalWrite(pin number, HIGH/LOW); delay(milliseconds);
  14. 14. Activity 2: ..and beep a buzzer Piezo buzzer 330
  15. 15. Activity 2: ..and beep a buzzer Assign pin 8 as tone pin Play a tone on tone pin with 200 Hz and 250ms Play a tone on tone pin with 600 Hz and 250ms
  16. 16. Use arrays for longer tunes
  17. 17. Challenge Build a circuit and write the Arduino sketch that will enable you to blink 4 LEDs intermittently & play a musical tone
  18. 18. Controlling RGB
  19. 19. Activity 4: Light sensing adafruit.com
  20. 20. Activity 4: Display light reading – Serial
  21. 21. Controlling servo motor
  22. 22. Activity 5: Controlling servo motor GND pin 0 +5V
  23. 23. Control servo with trimmer pot #include <Servo.h>
  24. 24. Recap #include <Servo.h> Servo myservo; myservo.attach (pin number); myservo.write (angle);
  25. 25. Reading from serial monitor #include <Servo.h> create a servo object called ‘myservo’ Start serial comm at 9600bps Assign servo to servo pin 9 Read analog pin 0, pass value to potLevel Convert range to 180 divisions Display something on serial monitor Tell servo to rotate
  26. 26. Replace pot with light sensor 10k
  27. 27. 10k
  28. 28. Ideas for projects
  29. 29. Thank you facebook.com/CRADLEsci

×