multi sensory communication 2/2

Post on 16-Apr-2017

59 Views

Category:

Design

2 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Sensor and Actuator

Ueki AtsuroSatoru Tokuhisa

2011.11.29

Parts

• Arduino UNO x1• USB cable x1• GROVE - Starter Bundle x 1pkg ※Please keep these parts until 12/20

Multi Sensory Communication 2

Additional Parts

• 3 axis Gyro x 1• 3 axis Accelerometer x 1• Sound Sensor x1• Vibrator x1• Rotary Angle Sensor x 1

Multi Sensory Communication 3

Download

• Source code– http://dl.dropbox.com/u/

326446/msc/02/source.zip

Multi Sensory Communication 4

Reference

• GROVE system– http://www.seeedstudio.com/wiki/GROVE_System

• Language Reference– http://arduino.cc/en/Reference/HomePage

• Tutorial– http://arduino.cc/en/Tutorial/HomePage

Multi Sensory Communication 5

Outline

• How to use Sensor– Rotary Angle Sensor – 3 axis Accelerometer – 3 axis Gyro

• How to use Actuator– Piezo Buzzer– Vibrator– Servo Morot

Multi Sensory Communication 6

Practice with GROVE

Multi Sensory Communication 7

GROVE Starter Kit

Multi Sensory Communication 8

Pack List

• Buttons X1• LEDs X1• Tilt X1• Buzzer X1• Rotary Angle Sensor X1• Temperature Sensor (Analog) X1

9Multi Sensory Communication

Pack List

• Smart Relay X1• Protoshield X1• LCD1602 Baseshield + LCD X1• Stem  Base Shield X1• GROVE Cable X10

10Multi Sensory Communication

Additional Parts

• 3 axis Gyro x 1• 3 axis Accelerometer x 1• Sound Sensor x1• Vibrator x1• Rotary Angle Sensor x 1

Multi Sensory Communication 11

Stem

Multi Sensory Communication

Analog InputA0-A5

Digital Input / OutputD1- D13

A1

A0

A2

A3

A4

A5

D1D2D3D4D5D6

D7D8D9D10D11D13 D12

12

I2C

Review

Multi Sensory Communication 13

digitalWrite/analogWrite

Multi Sensory Communication

LED Twig

14

Stem

Multi Sensory Communication

D13

15

Hello World!

void setup() { // initialize the digital pin as an output. // Pin 13 has an LED connected on most Arduino boards: pinMode(13, OUTPUT); }

void loop() { digitalWrite(13, HIGH); // set the LED on delay(1000); // wait for a second digitalWrite(13, LOW); // set the LED off delay(1000); // wait for a second}

16Multi Sensory Communication

Change the Blink Interval

void setup() { // initialize the digital pin as an output. // Pin 13 has an LED connected on most Arduino boards: pinMode(13, OUTPUT); }

void loop() { digitalWrite(13, HIGH); // set the LED on delay(100); // wait for a second digitalWrite(13, LOW); // set the LED off delay(100); // wait for a second}

17Multi Sensory Communication

Change the Blink Ratio

void setup() { // initialize the digital pin as an output. // Pin 13 has an LED connected on most Arduino boards: pinMode(13, OUTPUT); }

void loop() { digitalWrite(13, HIGH); // set the LED on delay(5); // wait for a second digitalWrite(13, LOW); // set the LED off delay(5); // wait for a second}

18Multi Sensory Communication

Change the Blink Ratio

void setup() { // initialize the digital pin as an output. // Pin 13 has an LED connected on most Arduino boards: pinMode(13, OUTPUT); }

void loop() { digitalWrite(13, HIGH); // set the LED on delay(1); // wait for a second digitalWrite(13, LOW); // set the LED off delay(9); // wait for a second}

19Multi Sensory Communication

Practice

• analogWrite(PWM)• http://arduino.cc/en/Reference/AnalogWrite

20Multi Sensory Communication

PWM

• PWM(Pulse Width Modulation)

D = τ/ TD : duty cycleτ: pulseT : transition

Multi Sensory Communication

ex: 0.25(D) = 1(τ)/4(T)

Pulse

time

21

PWM

Multi Sensory Communication

Analog Input x 6

Digital Input and Output x 14

3.3VGround

Ground

5V

Power Indicator

External Power

22

PWM~3, 5, 6, 9, 10, 11

Stem

Multi Sensory Communication

D11

23

Practice

void setup() { pinMode(11, OUTPUT); // 3, 5, 6, 9, 10, 11,}

void loop() { analogWrite(11, 255); // 0-255}

• analogWrite• http://arduino.cc/en/Reference/AnalogWrite

24Multi Sensory Communication

Sensor

Multi Sensory Communication 25

Practice 01

Multi Sensory Communication

Potentiometer Twig (Rotary angle sensor)

26

Stem

Multi Sensory Communication

A0

27

Arduino IDE

Multi Sensory Communication

Serial Monitor

Opens the serial monitor.

28

Practice 01 const int analogInPin = 0; int sensorValue = 0;

void setup() { Serial.begin(9600); // open the serial port at 9600 bps: }

void loop() { // read the analog in value: sensorValue = analogRead(analogInPin); Serial.println(sensorValue); delay(1000); }

29Multi Sensory Communication

-Rotary Angle Sensor ->A0-※Check the position of GND(Red)

Practice 01

• analogRead• Description

• Reads the value from the specified analog pin. • It will map input voltages between 0 and 5 volts into

integer values between 0 and 1023. • Syntax

• analogRead(pin) • Returns

• Int(0 to 1023)

30Multi Sensory Communication

Practice 01

• Serial.begin• Description

• Sets the data rate in bits per second (baud) for serial data transmission.

• For communicating with the computer, use one of these rates: 300, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, or 115200.

• Syntax• Serial.begin(speed)

31Multi Sensory Communication

Practice 01

• Serial.println• Description

• Prints data to the serial port as human-readable ASCII text followed by a carriage return character (ASCII 13, or '\r') and a newline character (ASCII 10, or '\n').

• Syntax• Serial.println(val)

Serial.println(val, format)

32Multi Sensory Communication

Advance 01

33Multi Sensory Communication

• How to check the present angle?• The angular range is 300 degrees • Hint

http://arduino.cc/en/Reference/Map

Advance 01 const int analogInPin = 0; int sensorValue = 0;

void setup() { Serial.begin(9600); // open the serial port at 9600 bps: }

void loop() { // read the analog in value: sensorValue = analogRead(analogInPin); sensorValue = map(sensorValue, 0, 1023, 0, 300); Serial.println(sensorValue); delay(1000); }

34Multi Sensory Communication

-Rotary Angle Sensor ->A0-※Check the position of GND(Red)

Practice 02

Multi Sensory Communication

3 axis accelerometer

35

Stem

Multi Sensory Communication

I2c

36

Practice 02

• Source Code• Practice02.txt

• Open Practice02.txt, copy the all, and paste it to Arduino IDE.

37Multi Sensory Communication

Arduino IDE

Multi Sensory Communication

Serial Monitor

Opens the serial monitor.

38

Practice 02

• Wire Library• This library allows you to communicate with I2C / TWI

devices. http://www.arduino.cc/en/Reference/Wire

• I2C• Serial communication method developed by Pilips

• Advantages: it can handle multiple signals with only two signal cables.

• Disadvantages: its program gets longer.

39Multi Sensory Communication

Practice 03

Multi Sensory Communication

3 axis Gyro

40

Stem

Multi Sensory Communication

I2c

41

Practice 03

• Source Code• Practice03.txt

• Open Practice03.txt, copy the all, and paste it to Arduino IDE.

42Multi Sensory Communication

Actuator

Multi Sensory Communication 43

Practice 04

Multi Sensory Communication

knob

44

x

Servo motor

Stem

Multi Sensory Communication 45

To knob

5V / GND to SERVO (RED / BROWN)

Digital 9 to SERVO(ORANGE)

Practice 04

• Source Code• Files > Example > Servo > Knob

46Multi Sensory Communication

Practice 04#include <Servo.h> Servo myservo; // create servo object to control a servo int potpin = 0; // analog pin used to connect the potentiometerint val; // variable to read the value from the analog pin void setup() { myservo.attach(9); // attaches the servo on pin 9 to the servo object } void loop() { val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)

val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180) myservo.write(val); // sets the servo position according to the scaled value delay(15); // waits for the servo to get there }

Multi Sensory Communication 47

Practice 05

Multi Sensory Communication

Vibrator

48

Stem

Multi Sensory Communication 49

Port 9 to vibrator

Practice 05

• Source Code• Files > Example > 3.Analog > Fading

50Multi Sensory Communication

Practice 06

Multi Sensory Communication

Vibrator

51

x

Mic

Stem

Multi Sensory Communication 52

Port 9 to vibrator

Analog 0 to mic

Practice 06

• Source Code• Practice06.txt

• Open Practice06.txt, copy the all, and paste it to Arduino IDE.

53Multi Sensory Communication

Practice 07

Multi Sensory Communication

Piezo Buzzer

54

Stem

Multi Sensory Communication 55

Port 8 to Piezo Buzzer

Practice 07

• Source Code• Files > Example > 2.Digital > toneMelody

56Multi Sensory Communication

Practice 08

Multi Sensory Communication

Piezo Buzzer

57

knob

x

Stem

Multi Sensory Communication 58

Port 8 to Piezo Buzzer

analog 0 to knob

Practice 08

• Source Code• Files > Example > 2.Digital > tonePitchFollower

59Multi Sensory Communication

Trial!!!

Multi Sensory Communication 60

accelerometer

x

Mic

top related