biohack academy arduinobiohackacademy.github.io › bha4 › class › 3 › pdf › 3 -...

14
BioHack Academy Arduino Picture by Bas Uterwijk

Upload: others

Post on 26-Jun-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: BioHack Academy Arduinobiohackacademy.github.io › bha4 › class › 3 › pdf › 3 - Arduino.pdf · Variables • char: 1 byte character value • byte: 8-bit unsigned number,

BioHack AcademyArduino

Picture by Bas Uterwijk

Page 2: BioHack Academy Arduinobiohackacademy.github.io › bha4 › class › 3 › pdf › 3 - Arduino.pdf · Variables • char: 1 byte character value • byte: 8-bit unsigned number,

Electricity vs Waterfall

Pixabay - Public Domain

Height=

Potential

Amount / time=

Current

Power = Potential x Current

Page 3: BioHack Academy Arduinobiohackacademy.github.io › bha4 › class › 3 › pdf › 3 - Arduino.pdf · Variables • char: 1 byte character value • byte: 8-bit unsigned number,

Water pipe metaphor

Page 4: BioHack Academy Arduinobiohackacademy.github.io › bha4 › class › 3 › pdf › 3 - Arduino.pdf · Variables • char: 1 byte character value • byte: 8-bit unsigned number,

Wiring scheme of the Stirrer

Page 5: BioHack Academy Arduinobiohackacademy.github.io › bha4 › class › 3 › pdf › 3 - Arduino.pdf · Variables • char: 1 byte character value • byte: 8-bit unsigned number,

Arduino

Sparkfun Electronics - CC-BY 2.0

Page 6: BioHack Academy Arduinobiohackacademy.github.io › bha4 › class › 3 › pdf › 3 - Arduino.pdf · Variables • char: 1 byte character value • byte: 8-bit unsigned number,

Digital electronics

0 1Off On

LOW HIGH

False TrueGND Vcc

Page 7: BioHack Academy Arduinobiohackacademy.github.io › bha4 › class › 3 › pdf › 3 - Arduino.pdf · Variables • char: 1 byte character value • byte: 8-bit unsigned number,

Arduino is Open Source

Digital

Analog

Power

Page 8: BioHack Academy Arduinobiohackacademy.github.io › bha4 › class › 3 › pdf › 3 - Arduino.pdf · Variables • char: 1 byte character value • byte: 8-bit unsigned number,

• Arduino IDE

• Setup() function• Loop() function

Programming

Page 9: BioHack Academy Arduinobiohackacademy.github.io › bha4 › class › 3 › pdf › 3 - Arduino.pdf · Variables • char: 1 byte character value • byte: 8-bit unsigned number,

Blinking an LED

• pinMode()• digitalWrite()• delay()

Output

Page 10: BioHack Academy Arduinobiohackacademy.github.io › bha4 › class › 3 › pdf › 3 - Arduino.pdf · Variables • char: 1 byte character value • byte: 8-bit unsigned number,

Button

Page 11: BioHack Academy Arduinobiohackacademy.github.io › bha4 › class › 3 › pdf › 3 - Arduino.pdf · Variables • char: 1 byte character value • byte: 8-bit unsigned number,

Reading a sensor

• Serial.begin()• digitalRead()• Serial.println()

Input

Page 12: BioHack Academy Arduinobiohackacademy.github.io › bha4 › class › 3 › pdf › 3 - Arduino.pdf · Variables • char: 1 byte character value • byte: 8-bit unsigned number,

Variables

• char: 1 byte character value• byte: 8-bit unsigned number, from 0 to 255• int: store 6-bit (2-byte) value, from -32,768 to 32,767• unsigned int• long: store 32 bits (4 bytes), from -2,147,483,648 to

2,147,483,647.• unsigned long• float: number that has a decimal point, 32 bits (4 bytes)

from -3.4028235E+38 to -3.4028235E+38• boolean: (8 bit) - simple logical true/false

Page 13: BioHack Academy Arduinobiohackacademy.github.io › bha4 › class › 3 › pdf › 3 - Arduino.pdf · Variables • char: 1 byte character value • byte: 8-bit unsigned number,

Function definition

[return type] [function name] ({arguments}){[ Code to execute ]}

int multiply(int num1, int num2){int result;result = num1 * num2;return result;}

Page 14: BioHack Academy Arduinobiohackacademy.github.io › bha4 › class › 3 › pdf › 3 - Arduino.pdf · Variables • char: 1 byte character value • byte: 8-bit unsigned number,

These slides are published by Waag Society under CC-BY-SA 4.0 license