107
Cassiopeia Ltd 2016 Electronics workshop Junior Makers at DimSumLabs 2015-2016

DSL Junior Makers - electronics workshop

Embed Size (px)

Citation preview

Cassiopeia Ltd 2016

Electronics workshopJunior Makers at DimSumLabs

2015-2016

Cassiopeia Ltd 2016

Robots!smart and interactive machines: input and output

inputs = sensors● button, switch● light sensor● distance sensor● microphone● keyboard, mouse● ...

outputs● lights, screens● sound● motors● ...

Cassiopeia Ltd 2016

Arduino = brain

inputs outputs

Cassiopeia Ltd 2016

Electricity = flowred = positive (+)black = negative (-) = ground

Cassiopeia Ltd 2016

Breadboard = connections

Cassiopeia Ltd 2016

LED = light emitting diode

Cassiopeia Ltd 2016

Push button with LED

Cassiopeia Ltd 2016

7 segment display

Cassiopeia Ltd 2016

hit minus game

● connect the 2 LEDs and resistors● connect the potentiometer● connect the buzzer● connect the button● connect the 7 segment display

power from a USB powerbank

or put your battery wires into the breadboard

Cassiopeia Ltd 2016

hit minus game

D4 means digital pin 4 on Arduino

A0 meansanalog input 0 on Arduino

GND is ground = 0V

Cassiopeia Ltd 2016

RGB coloursmixing paintsubtractive colours

mixing lightadditive colours

Cassiopeia Ltd 2016

colours are waves

Cassiopeia Ltd 2016

colours of the sun

Cassiopeia Ltd 2016

RGB colour LED

Cassiopeia Ltd 2016

Sound waves

Cassiopeia Ltd 2016

Speed of sound

Speed of sound =343 meter per second (m/s)through air

Speed of light =300,000,000 m/s1 million times faster than sound

Cassiopeia Ltd 2016

Ultrasound distance sensor● send out ultrasound pulse 40,000 Hertz● measure time it takes for reflection to arrive back (echo)● calculate distance from this time measurement (speed of sound)

Cassiopeia Ltd 2016

OLED screen

each pixel = LED128 x 64 pixelsfragile!

colour screen = each pixel is 3 LEDs (RGB)

Cassiopeia Ltd 2016

servo

slow strong motor to move things:● open/close● left/right● half a circle (0->180 degrees)

Cassiopeia Ltd 2016

simple robot: ultrasound distanceand servo

Cassiopeia Ltd 2016

potentiometer = variable resistor

create analog value: between 0 and 5V3 legs:

0 and 5V on outside legsvariable voltage on middle leg

Cassiopeia Ltd 2016

joystick = 2 potentiometers

joystick is 2 potentiometers on 1 stick:horizontal and vertical, x and y2 variable voltages, VRx and VRy

Cassiopeia Ltd 2016

pong game 1972!

Cassiopeia Ltd 2016

colours are waves, heat is also waves

Cassiopeia Ltd 2016

every object is a source of (mostly invisible) heat radiationspecial camera

thermal imaging

Cassiopeia Ltd 2016

Infrared motion sensor (PIR)● looking for infrared waves = heat● needs a few seconds to ‘warm up’● when it detects a change in infrared radiation > signal ON

Cassiopeia Ltd 2016

Infrared motion sensor (PIR)

simple test with battery, LED and resistor

Cassiopeia Ltd 2016

Santa Catcher

PIR motion sensorservo to open the window2 blinking LEDsRGB LED insidebuzzer tune

Cassiopeia Ltd 2016

Santa Catcher

Cassiopeia Ltd 2016

Long distance communication

radioc 1900

on/off switch

Cassiopeia Ltd 2016

Long distance communication - Morse code

Cassiopeia Ltd 2016

Radio module

nRF24 = 2.4GHz transceiverT = transmitR = receive

CrystalAntenna

Cassiopeia Ltd 2016

Aviation navigation with Morse radio beaconsRadio towers at known locations send out Morse signalsNon-Directional Beacons (NDB) 190-1750 kHz

Cassiopeia Ltd 2016

Morse decoder with radio

Connect the 7 wires on the radio to the Arduino

Be careful to use 3.3V, not 5V!

R= receiveT = transmit

Cassiopeia Ltd 2016

Scratch for Arduino s4a.cat

control the Arduino from Scratch

note: special program needs to be uploaded to the Arduino to make this work

Cassiopeia Ltd 2016

Scratch for Arduino - blink (digital output)

LED and resistorconnected toGND and D10

Cassiopeia Ltd 2016

Scratch for Arduino - traffic light

3x LED and resistorred: D10yellow: D11green: D12

now try this:

Cassiopeia Ltd 2016

Scratch for Arduino - joystick plotter

POSITION = joystick:5V, GND, A0, A1

PEN SIZE & COLOUR =2x potentiometer:5V, GND, middle: A2 and A3

CLEAR = button: 5V and D2

Cassiopeia Ltd 2016

Scratch for Arduino - joystick plotter

POSITION = joystick:5V, GND, A0, A1

PEN SIZE & COLOUR =2x potentiometer:5V, GND, middle: A2 and A3

CLEAR = button: 5V and D2 with pull-down resistor

Cassiopeia Ltd 2016

Scratch for Arduino - joystick position (analog input)

POSITION = joystick:5V, GND, A0, A1

Arduino analog range (blue)0 to 1023

Scratch screen range:X = -250 to 250Y = -200 to 200

Y

X

Cassiopeia Ltd 2016

Scratch for Arduino - analog ranges

Arduino analog signal: always 0 to 1023

Scratch screen:X = -250 to 250 (analog / 2) - 250Y = -200 to 200 (analog / 3) - 170

Pen colour: 0 to 200 analog / 5

Pen size: 0 to 255 analog / 4 (but divide by 20 otherwise too thick)

Cassiopeia Ltd 2016

Scratch for Arduino - digital input to Arduino (motion)

digital = ON or OFF1 or 0true or false

PIR motion sensor on D25V and GND

LED with resistor on D10

Cassiopeia Ltd 2016

Scratch for Arduino - digital input to Arduino (button)

button for D3 and 5VON or OFF, true or false

connect D3 also to resistor to GNDotherwise we cannot be sure what happens when button is not pressed= PULL DOWN RESISTOR

Cassiopeia Ltd 2016

Scratch for Arduino - analog output on Arduino (LED)

digital = ON or OFF, 1 or 0analog = a RANGE of values

LED with resistor on D9

for Arduino analog out = 0 to 2550 = no power255 = full power

Cassiopeia Ltd 2016

Scratch for Arduino - analog output on Arduino (servo)

analog = a RANGE of values

SERVO on D8 (orange)5V (red) and GND (brown)

position from 0 to 180 degrees

Cassiopeia Ltd 2016

Scratch for Arduino - Monkey Catcher

● monkey is hiding

○ when motion detected, monkey appears on the screen○ switch LED on○ monkey says hello

■ change monkey’s colour with LDR sensor■ change monkey’s size with potentiometer■ push button to let the monkey go and hide again

○ monkey says bye○ switch LED off○ back to start

Cassiopeia Ltd 2016

S4A- Monkey Catcher● PIR motion on D2

with 5V and GND● button on D3 (with pull-down

resistor)● LED + resistor on D10● LDR + resistor on A0● potentiometer on A1

start

loop

Cassiopeia Ltd 2016

Infrared LED and infrared detectorInfrared LED = emitter (white colour, L1) as with all LED’s, long leg = positive

Infrared detector (black colour, T1) ATTENTION: long leg goes to negative!

220Ω10kΩ

5V

A0white

black

Cassiopeia Ltd 2016

Infrared detector = voltage divider

220Ω10kΩ

5V

A0

5V

GND = 0V

0 to 5V analog input 0 to 1023

1023

0

white

black

Cassiopeia Ltd 2016

S4A - analog input to Arduino (IR emitter + detector)

0-5V signal between detector and resistor to AO

220Ω10kΩ

5V

A0white

black

Cassiopeia Ltd 2016

S4A - analog input to Arduino (IR emitter + detector)

ball bounces around

when IR is blocked, the ball stops and drum is played

Cassiopeia Ltd 2016

S4A - analog input to Arduino (IR distance)

IR distance sensor

ball moves according to IR reflection

Cassiopeia Ltd 2016

S4A - analog input to Arduino (IR distance game)

ball moves horizontally according to IR reflection,avoid the bee!

keep ball codeadd sprite for bee

Cassiopeia Ltd 2016

S4A - pong game: overview

use potentiometer to control the paddle position

ball bounces around

points increase with each hit

change the speed with a second potentiometer

start again with button press

Cassiopeia Ltd 2016

S4A - pong game: step 1

connect potentiometer on breadboard: outside legs to 5V and GND, middle to A0

check changing value

rename the sprite to ‘paddle’

paint a new costume for the paddle

Cassiopeia Ltd 2016

S4A - pong game: step 2

write script for paddleand test

Cassiopeia Ltd 2016

S4A - pong game: step 3

add a new sprite of arduino typecall it ballchange costume to a ball

write script for ballmove and bounce on edgeif touch paddle, bounce back

Cassiopeia Ltd 2016

S4A - pong game: step 4

edit stage: add red line

add check to ball script

add button on breadboard:one side 5Vone side D2 and resistor to GND

Cassiopeia Ltd 2016

S4A - pong game: step 5

add variable ‘points’to count the hits

set points=0 at startadd 1 point when hitset points=0 when start again

Cassiopeia Ltd 2016

S4A - pong game: step 6

add a potentiometer to control the speedoutside legs to 5V and GND, inside A1

add variable ‘speed’

set speed to analog reading of A1use this variable the ‘move’

speed can vary from 0 to 20:A1 (0 to 1023) divided by 50

Cassiopeia Ltd 2016

Mobile phone communication

Cassiopeia Ltd 2016

Mobile phone technology

voice

sound wave

mic

electricity

SIM

radio wave

radio wave electricity

SIM speaker ear

sound wave

phone

phone

micSIM

Cassiopeia Ltd 2016

Arduino phone with SIM800 module

Insert SIM card correctly!(contacts facing the board)

Green LED = network statusRed LED = call status

Press button to call number 1 or 2Press any button to hang up

Press any button to pick up a call

Cassiopeia Ltd 2016

Arduino phone with SIM800 module

Cassiopeia Ltd 2016

Radio technology

radio wave electronicsignal

SIM speaker ear

sound wave

phone

Cassiopeia Ltd 2016

Arduino FM radio with SIM800 module

Cassiopeia Ltd 2016

Amplifier: increase amplitude = volume

Multiplicator = GAIN

Cassiopeia Ltd 2016

Audio amplifier

Amplified signal = louder!

SIM800speaker signal

Cassiopeia Ltd 2016

Cassiopeia Ltd 2016

Sound waves: frequency (= pitch)

Frequency unit: HERTZ (Hz) = cycles per second

Cassiopeia Ltd 2016

Sound waves: amplitude (= volume)

Amplitude is the power of the wave = volume

Cassiopeia Ltd 2016

Sound waves: shape (= timbre) Pure wave: SINEOnly 1 frequency

Other shapes make different soundsCheck http://onlinetonegenerator.com/

Only sine is a pure single frequency sound, other shapes add frequencies

Cassiopeia Ltd 2016

Sound waves: shape Pure wave: SINEOnly 1 frequency

Different instruments produce their own wave shape, also human voices

Same basic note (frequency), but other frequencies come up too

Cassiopeia Ltd 2016

Sound waves: shape and spectrum

Almost pure SINE wave:1 strong frequency

Different instruments produce their own wave shape

Same basic note (frequency), but other frequencies come up too = ‘harmonics’

SPECTRUM shows us the frequencies

Cassiopeia Ltd 2016

Arduino SPECTRUM Analyser

Microphone with amplifier

RGB LED reacts to different frequencies: colour depends on dominant frequency

OLED shows the spectrum with 6 bars: 400/800/1600/3000/6000/12000 Hz

Cassiopeia Ltd 2016

Test spectrum analyser

You can find a lot of test frequencies on Youtube..

Cassiopeia Ltd 2016

Arduino wire loop game

Go from Start to Finish without touching the wire while the time is counting..

The handle is connected to GND, and the wire is connected to D7 as input.Also 2 inputs for Start and Finish.

Cassiopeia Ltd 2016

Arduino wire loop game

Cassiopeia Ltd 2016

DSL laser cutter: how it works

CO2 laser:Infrared light = invisible!

Cassiopeia Ltd 2016

DSL laser cutter: cutting and engraving

CO2 laser:Infrared light = invisible!

CUTTING: a line going through the material

ENGRAVING: an image/letters on the surface

Cassiopeia Ltd 2016

Arduino servo insect

Servo has 3 wires:● 5V● GND● Signal (position)

Cassiopeia Ltd 2016

Arduino servo insect - connectionsServo has 3 wires:

● 5V● GND● Signal (position)

Servo signals on D8 and D9

Large capacitor between 5V and GND

Potentiometer to A0: pace=timePotentiometer to A1: span=max angle

Cassiopeia Ltd 2016

WIFI project: web server

Information is stored on SERVERS:

● Websites● Files such as music, video

We use the INTERNET to connect to the servers

Cassiopeia Ltd 2016

WIFI project: web server

We connect to the INTERNET over WIFI = wireless(or by cable = ethernet)

We connect to a Wireless Router or ACCESS POINT (hotspot)

The router is connected to the internet via cables

INTERNET (ADSL, fiber optic..)

Cassiopeia Ltd 2016

WIFI project: web server

We create a WIFI ACCESS POINT

We use a client (laptop, phone, tablet) to connect to this WIFI network

We visit webpages stored on the serverhttp://esp

Local network only, not connected to INTERNET

Our project = WIFI access

point + server

INTERNET

Cassiopeia Ltd 2016

WIFI project: ESP8266 microcontroller

ESP8266-01 (ESP) vs Arduino UNO

Cassiopeia Ltd 2016

WIFI project: RGB control and DHT sensor

Arduino only used for powersupply (3.3V and 5V)

Cassiopeia Ltd 2016

Low power I/O Directly to pin: very low powerPin + GND

5V power (5V + GND) and data pin(s)Data pin = very low power

I/Oinput/output

Cassiopeia Ltd 2016

High power switching

output

Low power High power5V DC 220V AC

RELAY

Cassiopeia Ltd 2016

Relay NC COM NO

DC+=5V DC-=GND IN=data

HIGHpower

LOWpower

Cassiopeia Ltd 2016

Relay to switch socket

Cassiopeia Ltd 2016

Motor control with H bridge

DC motor (direct current)Magnetic power2 wires

How to change direction?

Cassiopeia Ltd 2016

Motor control with H bridge

Cassiopeia Ltd 2016

Motor control with H bridge: L293D

Motor driver IC2x H-bridge = 2 motors2 pins for switches, 1 pin for power control

1 pin for external power

Cassiopeia Ltd 2016

WiFi lantern with Neopixel RGB strip

Cassiopeia Ltd 2016

WiFi lantern: components

5V 3.3V

Cassiopeia Ltd 2016

WiFi lantern: soldering

Cassiopeia Ltd 2016

Auduino 4 step sequencerAuduino =an Arduino based synthesizer

A sequencer =a device to generate a sequence of notes

Cassiopeia Ltd 2016

Auduino 4 step sequencer:breadboard version

Cassiopeia Ltd 2016

Auduino 4 step sequencerin box:front panel

Cassiopeia Ltd 2016

Auduino 4 step sequencer: PCB soldering

Cassiopeia Ltd 2016

Auduino 4 step sequencer: PCB wiring and amp

Cassiopeia Ltd 2016

Gyroscope and accelerometer sensor

How does a phone know how we are holding it? (orientation)

● Gyro● Accelerometer

Cassiopeia Ltd 2016

Sensors in mobile phone

What other sensors does a phone have?● Gyro● Accelerometer

● Compass● GPS● Barometer● Fingerprint sensor● Proximity sensor● Light sensor● Thermometer ● Pedometer● Heart rate monitor

Cassiopeia Ltd 2016

Position: roll, pitch, yaw

Cassiopeia Ltd 2016

Arduino and gyro module

GY-512 (IMU - 6DOF)Gyroscope + accelerometer

Cassiopeia Ltd 2016

Arduino gyro game

● tilt the sensor to move the ball around

● do not touch the borders● try to catch as many squares as

possible within 1 minute