A Shallow Embedded, Type Safe Extendable DSL for the Arduino. Pieter Koopman
|
|
- Oswald Whitehead
- 5 years ago
- Views:
Transcription
1 A Shallow Embedded, Type Safe Extendable DSL for the Arduino Pieter Koopman
2 what is an Arduino? open source microprocessor board Ø 8-bit ATMega328 Ø 16 MHz Ø 32 KB flash memory Ø 2 KB RAM Ø big input / output connectors (14D, 6A) Ø USB port Ø boot loader Ø 1 on-board LED Ø cheap 2
3 why an Arduino very suited to handle sensors and actuators Ø sensors: buttons, temperature, heart rate, GPS,.. Ø actuators: lights, motors, robots, LCD, relay,.. Ø many shields available LCD, relay, GPS, keypad,.. shields can be stacked easy experimentation hence very suited for simple control tasks Ø integrate this with itasks Ø IoT Internet of Things 3
4 software on the Arduino no multitasking / no threads no operating system, just a tiny boot-loader your program has to do everything Ø setup: initialisation Ø loop: repeated ever after the setup programming language(s) for Arduino Ø C for all basic things Ø C++ like objects to control shields 4
5 'hello world' for Arduino blink the LED boolean ledon = false; void setup() { pinmode(13, OUTPUT); digitalwrite(13, LOW); } void loop() { ledon = not ledon; digitalwrite(13, ledon); delay(500); } busy-wait loop L L entire Arduino is sleeping 5
6 better 'hello world' for Arduino blink the LED boolean ledon = false; long lasttime = 0; void setup() { pinmode(13, OUTPUT); digitalwrite(13, LOW); } void loop() { } if (millis() / 500 > lasttime) { } ledon = not ledon; digitalwrite(13, ledon); lasttime += 1; J no delay 6
7 servomotor rotary actuator with control of angular position Ø duration of input pulse controls position PWM: pulse width modulation Ø Arduino ports can generate PWM signals 7
8 servo sweep program #include <Servo.h> Servo s; int pos = 10; int step = 1; long time = 0; // include library // create servo object // servo position // angle change // time of last change void setup() { s.attach( A5 ); // attach servo on pin A5 to object } void loop() { if (millis() / 25 > time) { // 40 step per second time += 1; pos += step; if (pos > 170 pos < 10) { // outside preferred angle region? step = - step; // turn the direction of the servo pos += step; } s.write( pos ); // set servo angle in degrees } } easy to combine with blink program 8
9 why a Domain Specific Language? the Arduino is very suited for low level I/O Ø we need this kind of control in itask, e.g. IoT running Clean on the Arduino is not feasible programming the Arduino in C and interfacing it with itask is tedious, error-prone detention work Embedded Domain Specific Language bridge the gap Ø single source of program Ø strong typing Ø extendable DSL new shields without recompiling Ø complete DSL control the parts of Clean inherited Ø multiple views compile, simulate, analyse,.. 9
10 implementing a DSL 1 a library with function and data types Ø shallow embedding of DSL Ø like the itask system: a DSL for task oriented programs Clean with EDSL program must run on Arduino this requires Clean on the Arduino Ø this cannot work Ø 32KB flash, 2KB ram, 8 bit, 16 MHz Ø 10
11 implementing a DSL 2 a library with function and data types Ø like the itask system: a DSL for task oriented programs running Clean with EDSL program on PC, remote control of Arduino Ø e.g. Firmata protocol, like harduino Ø can work requires much interaction between PC and Arduino Ø we want independent tasks at the Arduino Ø 11
12 implementing a DSL 3 EDSL should have clear border Ø DSL does not inherit everything from Clean DSL is an algebraic data type, deep embedding :: Expr = Num Int Bool Bool Add Expr Expr.. this does not prevent runtime type errors in DSL p = Add (Int 7) (Bool False) Ø we want a strongly typed DSL Ø 12
13 implementing a DSL 4 EDSL should have clear border Ø DSL does not inherit everything from Clean DSL is an generalized algebraic data type, GADT :: Expr a = Lit a Add (BM a Int) (Expr Int) (Expr Int).. this prevents runtime type errors in DSL p = Add bm (Lit 7) (Lit False) // this is rejected by the compiler q = Add bm (Lit 7) (Lit 36) Ø this is strongly typed DSL, Ø but the DSL cannot be extended without recompilation Ø 13
14 implementing a DSL 5 EDSL should have clear border Ø DSL does not inherit everything from Clean DSL is set of type constructor classes Ø strongly typed, have a border, have multiple views class expr v where lit :: t - > v t add :: (v Int) (v Int) - > v Int p :: a Int expr x p = add (lit 7) (lit 36) this solves our problems Ø 14
15 Show view of this DSL the DSL class expr v where lit :: t - > v t tostring t add :: (v Int) (v Int) - > v Int each view is an instance of this class Ø e.g. show = conversion to list of strings :: Show a = S [String] instance expr Show where we do not use argument a, but it must be there lit a = S [tostring a] add (S x) (S y) = S (["("] ++ x ++ ["+"] ++ y ++ [")"]) 15
16 Show view of this DSL 2 class expr v where lit :: t - > v t tostring t add :: (v Int) (v Int) - > v Int :: Show a = S [String] instance expr Show where lit a = S [tostring a] add (S x) (S y) = S (["("] ++ x ++ ["+"] ++ y ++ [")"]) Ø a DSL program p :: (v Int) expr v p = add (lit 7) (lit 36) Ø evaluating this program in the Show view Start = strings where (S strings) = p this yields ["(","7","+","36",")"] 16
17 Evaluation view of this DSL the DSL class expr v where lit :: t - > v t tostring t add :: (v Int) (v Int) - > v Int each view is an instance of this class Ø e.g. eval = conversion to single value :: Eval a = E a instance expr Eval where lit a = E a add (E x) (E y) = E (x + y) here we use argument a 17
18 Eval view of this DSL 2 class expr v where lit :: t - > v t tostring t add :: (v Int) (v Int) - > v Int :: Eval a = E a instance expr Eval where lit a = E a add (E x) (E y) = E (x + y) Ø a DSL program p :: (v Int) expr v p = add (lit 7) (lit 36) Ø evaluating this program in the both views Start = (val, strings) where (E val) = p (S strings) = p this yields (43,["(","7","+","36",")"]) 18
19 extending the DSL leave class expr untouched, define a new class Ø we do not break existing code and views class expr v where lit :: t - > v t tostring t add :: (v Int) (v Int) - > v Int class expr2 v where And :: (v Bool) (v Bool) - > v Bool Not :: (v Bool) - > v Bool equ :: (v a) (v a) - > v Bool ==, tostring a unchanged 19
20 extending the DSL 2: views make instances of Show and Eval for expr2 :: Show a = S [String] // unchanged instance expr2 Show where And (S x) (S y) = S (["("] ++ x ++ ["&&"] ++ y ++ [")"]) Not (S x) = S (["(Not"] ++ x ++ [")"]) equ (S x) (S y) = S (["("] ++ x ++ ["=="] ++ y ++ [")"]) :: Eval a = E a // unchanged instance expr2 Eval where And (E x) (E y) = E (x && y) Not (E x) = E (not x) equ (E x) (E y) = E (x == y) q :: (v Bool) expr, expr2 v q = Not (equ p (lit 42)) execution yields (True, ["(Not","(","(","7","+", "36", ")","==","42",")",")"]) 20
21 borders of DSL the classes expr and expr2 are our DSL class dsl t expr, expr2 t there is a clear difference between Ø 7, it has type Int Ø lit 7, it has type v Int expr v this is exactly what we want Ø we can make a view for dsl, without having to implement it for everything in Clean 21
22 strong typing the Clean type system detects statically any type error in our DSL Ø for instance adding an integer and a Boolean err = add (lit 7) (lit True) Ø Type error :"argument lit" cannot unify types: Int Bool Ø comparing an integer and a Boolean err2 = equ (lit 7) (lit True) Ø Type error :"argument lit" cannot unify types: Bool Int this prevents runtime type errors in our DSL 22
23 show in combinators hide the implementation of show a little :: Show a = S [String] (+.+) infixr 5 :: (Show a) (Show b) - > Show c (+.+) (S a) (S b) = S (a ++ b) brac :: (Show a) - > Show b brac s = S ["("] +.+ s +.+ S [")"] the view for our DSL becomes instance expr Show where lit a = S [tostring a] add x y = brac (x +.+ S ["+"] +.+ y) instance expr2 Show where And x y = brac (x +.+ S ["&&"] +.+ y) Not x = brac (S ["Not"] +.+ x) equ x y = brac (x +.+ S ["=="] +.+ y) why are these type arguments different? 23
24 variables in our DSL simple approach Ø state = list of values Ø dynamic to put different type of variables in one list :: State :== [Dyn] :: Eval a = E (State - > (a, State)) monad (>>==) infixl 1 :: (Eval a) (a - > Eval b) - > Eval b (>>==) (E f) g = E \s. let (a,s2) = f s; (E h) = g a in h s2 rtrn :: a - > Eval a rtrn a = E \s - > (a,s) 24
25 variables in our DSL 2 update eval view of our DSL instance expr Eval where lit a = rtrn a add x y = x >>== \a. y >>== \b. rtrn (a + b) instance expr2 Eval where And x y = x >>== \a. y >>== \b. rtrn (a && b) Not x = x >>== \a. rtrn (not a) equ x y = x >>== \a. y >>== \b. rtrn (a == b) 25
26 variables in our DSL 3 add variables to our DSL Ø use index in list as identification class var v where var :: Int - > v a dyn a instance var Show where var v = S ["v" + tostring v] instance var Eval where var v = E \s.(fromjust (fromdyn (s!! v)), s) example p2 :: (v Int) expr, var v p2 = add (lit 7) (var 1) 26
27 limitations of these variables type system cannot check indices Ø index can be wrong p3 :: (v Int) expr, var v p3 = add (lit 7) (var - 1) Ø types of variable can be inconsistent p4 :: (v Bool) expr, var v p4 = And (equ (lit 7) (var 1)) (var 1) Int it is dangerous when the user handles indices Ø let the system generate them Bool 27
28 better variables DSL implementation assigns numbers Ø expression is function that accepts a variable class var v where var :: t ((v t)- >v t) - > v t dyn, tostring t Ø application p2 :: (v Int) expr, var v p2 = var 3 \x.add (lit 7) x Ø implementing views instance var Show where this yields (10, "v = 3 in (7 + v)") fresh name required var v f = name +.+ S [" = " + tostring v + " in "] +.+ f name where name = S ["v"] instance var Eval where var v f = E (\s.(length s, s ++ [todyn v])) >>== \n- >f (E \s.(fromjust (fromdyn (s!! n)), s)) 28
29 variables are special suppose we add an assignment assign x (add x (lit 1)) or x = x + 1 Ø variables are allowed on the left-hand side array selection might be added Ø lit 1 is not allowed on the left-hand side, our type system should prevent that add an additional type to control access Ø Read: read-only expressions Ø Write: read and write access :: Read = Read :: Write = Write add these types to every class in the DSL 29
30 new type classes class expr v where lit :: t - > v t Read tostring t add :: (v Int p) (v Int q) - > v Int Read class expr2 v where And :: (v Bool p) (v Bool q) - > v Bool Read Not :: (v Bool p) - > v Bool Read equ :: (v a p) (v a q) - > v Bool Read ==, tostring a new variable class class var v where var :: t ((v t Write)- >v t p) - > v t p dyn, tostring t views get also an additional argument :: Show a p = S [String] 30
31 sequencing expressions once we have a global state it make sense to sequence expressions Ø first expression can change state Ø second expression is executed with that state class sequ v where sequ :: (v a p) (v b q) - > v b q instance sequ Show where sequ x y = S ["sequ"] +.+ x +.+ y instance sequ Eval where sequ x y = x >>== \_. y 31
32 assignment: change the state assign x (add x (lit 1)) or x = x + 1 write read how to distinguish x and x? the assign function knows the context Ø tell it to the Eval view :: RW a = R W a :: Eval a p = E ((RW a) State - > (a, State)) 32
33 the assignment class readvar :: Var (RW a) [Dyn] - > (a, [Dyn]) dyn a readvar n R s = (fromjust (fromdyn (s!! n)), s) readvar n (W a) s = (a, updateat n (todyn a) s) class var v where var :: t ((v t Write)- >v t p) - > v t p dyn, tostring t instance var Eval where var v f = E (\r s.(length s, s ++ [todyn v])) >>== \n. f (E (readvar n)) class assign v where assign :: (v t Write) (v t p) - > v t q dyn, tostring t instance assign Eval where assign (E v) e = e >>== \a. E \r s.v (W a) s 33
34 using this class dsl t expr, expr2, var, assign, sequ t p3 :: (v Int Read) dsl v p3 = var 15 \n. sequ (assign n (add n (lit 6))) (add n n) Ø showing p3 yields v = 15 in sequ (v = (v + 6)) (v + v) Ø evaluating p3 yields 42 compiler rejects any improper assignment we cannot use undefined or ill typed variables Ø 34
35 back to a DSL for the Arduino how to write C++ code in Clean 35
36 design of the DSL we need a state to store information Ø next iteration of loop needs to know what we are doing Ø hence we add an assignment to fields in the state we need to control heap usage, no recursive types use shallow embedding for easy extension of DSL Ø language is based on functions use classes to allow multiple views Ø one instance for each view Ø currently two views: compile + simulate in itask 36
37 DSL constants and operators each DSL element is a type constructor class Ø argument v: the view this view v has two arguments Ø t: the type of this construct Ø p: Read / Write behaviour of this construct class lit v where lit :: t - > v t Read tostring, type, tocode t class arith v where (+.) infixl 6 :: (v t p) (v t q) - > v t Read type, + t (-.) infixl 6 :: (v t p) (v t q) - > v t Read type, - t class eq v where (=.=) infix 4 :: (v t p) (v t q) - > v Bool Read type, Eq t class logical v where ~. :: (v Bool p) - > v Bool p 37
38 assignment and variables class assign v where (=.) infixr 1 :: (v t Write) (v t q) - > v t Read type t variable has same type as value written variable must be writable (no assignment to a lit ) class bind v where (>==) infixr 0 :: (v t p) ((v t Read)- >(v u q)) - > (v u q) class vardef v where type, type2code t & type u int :: ((v Int Write) - > ARDSL (v t p) (v u q)) - > ARDSL (v t p) (v u q) :: ArDSL a b = {setup :: a, loop :: b} 38
39 'Hello world' in ARDSL helloworld = boolean \ledon. int \lasttime. ardsl { } setup = pinmode D13 OUTPUT :. digitalwrite D13 (lit False), loop = If (millis /. lit 500 >. lasttime) ( ) ledon =. ~. ledon >== \b. digitalwrite D13 b :. lasttime =. lasttime +. lit 1 define state variables enumeration i.s.o. integer operators have extra. 39
40 servo sweep in ARDSL servosweep = servo \s. int \pos. int \step. long \time. ardsl { setup = pos =. lit 10 :. step =. lit 1 :. attach s A5, loop = If (millis /. lit 25 >. time) ( time =. time +. lit 1 :. pos =. pos +. step :. If (pos >. lit 170. pos <. lit 10) ( step =. lit 0 -. step ) :. writes s pos ) } 40
41 "Hello world" and ticks on LCD testlcd = int \n. liquidcrystal [] \lcd. ardsl { setup = begin lcd (lit 16) (lit 2) :. print lcd (lit "hello world"),loop = } setcursor lcd (lit 1) (lit 1) :. n =. n +. lit 1 :. setcursor lcd (lit 0) (lit 1) :. print lcd n :. delay (lit 1000) // ARDSL knows default pins // better check the time 41
42 adding a LCD shield :: LCD class lcd v where begin :: (v LCD r) (v Int p) (v Int q) - > v Int Read print :: (v LCD r) (v t p) - > v Int Read printcode t setcursor :: (v LCD r) (v Int p) (v Int q) - > v Void Read liquidcrystal :: [DigitalPin] no assignment to this variable abstract type methods of C++ class LCD ((v LCD Read) - > ARDSL (v t p) (v u q)) - > ARDSL (v t p) (v u q) 42
43 compiling ARDSL an instance of the classes that emits C-code use Arduino IDE to compile and load this code :: Code t p = Code (CompState - > CompState) :: *CompState = { gcode :: *File // code to this file, idnum :: Int // fresh identifiers, indnt :: Int // indentation } type arguments are not used here 43
44 compiling ARDSL to Arduino ARDSL C++ as intermediate language C++ 44
45 compiling: basic cases instance lit Code where lit x = tocode x tocode :: t - > Code b p tocode t tocode a = addcode (tocode a) class tocode t :: t - > String instance tocode Int where tocode x = tostring x instance tocode Bool where tocode b b = "true"; = "false" instance arith Code where (+.) x y = codeop2 x " + " y (-.) x y = codeop2 x " - " y codeop2 :: (Code t p) String (Code u q) - > Code c r codeop2 x n y = brackets (x +.+ addcode n +.+ y) 45
46 compiling: bind make a new variable and let Clean substitute it class bind v where (>==) infixr 0 :: (v t p) ((v t Read)- >(v u q)) - > (v u q) instance bind Code where (>==) x f = genname \var. type, type2code t & type u type2code x +.+ addcode var +.+ addcode " = " +.+ x +.+ addcode ";" +.+ nl +.+ f (addcode var) 46
47 compiling: variable definition make a new variable and let Clean substitute it class vardef v where int :: ((v Int Write) - > ARDSL (v t p) (v u q)) - > ARDSL (v t p) (v u q) instance vardef Code where int f = {ardsl & defs = [def: ardsl.defs]} where ardsl = f (addcode name) name = newname ardsl def = {name = name, type = "long", args = ""} 47
48 next view: simulate DSL as itask evaluation in itask simulator Ø executes loop in each step :: Eval a p = Eval ((RW a) State - > (a, State)) :: State = { vars :: [(String, Dyn)], dpins :: [(DigitalPin, Bool)], apins :: [(AnalogPin, Int)], time :: Int } simulate :: (ARDSL (Eval a p) (Eval b q)) - > Task Void 48
49 to do / future work more complex types in DSL, e.g. array user defined functions more shields fancy simulation of shields step-by-step simulation serial communication integration with itask Ø serial communication: message based Ø itask: task communicate by changes in shared state.. 49
50 achieved type safe extendable DSL for the Arduino Ø Clean checks types for the DSL Ø DSL uses only type-safe and properly defined variables Ø DSL does not inherit Clean as a side-effect, Clean is just the macro layer for ARDSL Ø we can add new constructs one-by-one Ø we can add new views one-by-one occasionally a minor change: add a class restriction (almost) solves Wadler's expression problem ['98] Ø The goal is to define a datatype by cases, where one can add new cases to the datatype and new functions over the datatype, without recompiling existing code, and while retaining static type safety 50
51 exercises 1. "Hello CEFP" on lcd (8,9,4,5,6,7) from Arduino IDE Ø connect Arduino, start IDE, select port and UNO, write program, check program, upload it 2. "Hello CEFP" on lcd from ARDSL Ø generate C++ from ARDSL, copy this to Arduino IDE 3. print the key pressed on the lcd Ø Ø key represented by voltage on A0, web: arduino.cc use keyswitch from lcd.dcl 4. make a clock on the lcd, keys to adjust time 5. add a += operator to ARDSL 6. add read and write to serial port to ARDSL 51
52 hello CEFP #include <LiquidCrystal.h> LiquidCrystal lcd(8,9,4,5,6,7); int ticks; void setup() { lcd.begin(16, 2); lcd.print("hello CEFP"); } void loop() { } if (millis() / 500 > ticks) { lcd.setcursor(0,1); } lcd.print(ticks); ticks += 1; 52
53 on your own computer download Arduino IDE: arduino.cc special driver for this Arduino Ø see Ø CH340 micro-usb driver at (in Chinese): 53
3.The circuit board is composed of 4 sets which are 16x2 LCD Shield, 3 pieces of Switch, 2
Part Number : Product Name : FK-FA1416 MULTI-FUNCTION 16x2 LCD SHIELD This is the experimental board of Multi-Function 16x2 LCD Shield as the fundamental programming about the digits, alphabets and symbols.
More informationUSER MANUAL ARDUINO I/O EXPANSION SHIELD
USER MANUAL ARDUINO I/O EXPANSION SHIELD Description: Sometimes Arduino Uno users run short of pins because there s a lot of projects that requires more than 20 signal pins. The only option they are left
More informationComputing Science: Master s Thesis
Computing Science: Master s Thesis Task Oriented Programming and the Internet of Things Author: Mart Lubbers BSc. mart@martlubbers.net Supervisor: prof. dr. dr.h.c. ir. M.J. Plasmeijer Second reader: dr.
More informationLab 01 Arduino 程式設計實驗. Essential Arduino Programming and Digital Signal Process
Lab 01 Arduino 程式設計實驗 Essential Arduino Programming and Digital Signal Process Arduino Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It's
More informationkeyestudio Keyestudio MEGA 2560 R3 Board
Keyestudio MEGA 2560 R3 Board Introduction: Keyestudio Mega 2560 R3 is a microcontroller board based on the ATMEGA2560-16AU, fully compatible with ARDUINO MEGA 2560 REV3. It has 54 digital input/output
More informationArduino Prof. Dr. Magdy M. Abdelhameed
Course Code: MDP 454, Course Name:, Second Semester 2014 Arduino What is Arduino? Microcontroller Platform Okay but what s a Microcontroller? Tiny, self-contained computers in an IC Often contain peripherals
More informationThe Arduino Briefing. The Arduino Briefing
Mr. Yee Choon Seng Email : csyee@simtech.a-star.edu.sg Design Project resources http://guppy.mpe.nus.edu.sg/me3design.html One-Stop robotics shop A-Main Objectives Pte Ltd, Block 1 Rochor Road, #02-608,
More informationLab-3: LCDs Serial Communication Analog Inputs Temperature Measurement System
Mechatronics Engineering and Automation Faculty of Engineering, Ain Shams University MCT-151, Spring 2015 Lab-3: LCDs Serial Communication Analog Inputs Temperature Measurement System Ahmed Okasha okasha1st@gmail.com
More informationDomain Specific Languages for Small Embedded Systems
Domain Specific Languages for Small Embedded Systems Mark Grebe Department of Electrical Engineering and Computer Science PADL 2016 The University of Kansas April 27, 2018 Small Embedded Systems Small,
More informationSTEPD StepDuino Quickstart Guide
STEPD StepDuino Quickstart Guide The Freetronics StepDuino is Arduino Uno compatible, uses the ATmega328P Microcontroller and works with most Arduino software. The StepDuino can be powered automatically
More informationINDUSTRIAL TRAINING:6 MONTHS PROGRAM TEVATRON TECHNOLOGIES PVT LTD
MODULE-1 C Programming Language Introduction to C Objectives of C Applications of C Relational and logical operators Bit wise operators The assignment statement Intermixing of data types type conversion
More informationTANGIBLE MEDIA & PHYSICAL COMPUTING INTRODUCTION TO ARDUINO
TANGIBLE MEDIA & PHYSICAL COMPUTING INTRODUCTION TO ARDUINO AGENDA ARDUINO HARDWARE THE IDE & SETUP BASIC PROGRAMMING CONCEPTS DEBUGGING & HELLO WORLD INPUTS AND OUTPUTS DEMOS ARDUINO HISTORY IN 2003 HERNANDO
More informationARDUINO. By Kiran Tiwari BCT 2072 CoTS.
ARDUINO By Kiran Tiwari BCT 2072 CoTS www.kirantiwari.com.np SO What is an Arduino? WELL!! Arduino is an open-source prototyping platform based on easy-to-use hardware and software. Why Arduino? Simplifies
More informationCTEC 1802 Embedded Programming Labs
CTEC 1802 Embedded Programming Labs This document is intended to get you started using the Arduino and our I/O board in the laboratory - and at home! Many of the lab sessions this year will involve 'embedded
More informationARDUINO EXPERIMENTS ARDUINO EXPERIMENTS
ARDUINO EXPERIMENTS IR OBSTACLE SENSOR... 3 OVERVIEW... 3 OBJECTIVE OF THE EXPERIMENT... 3 EXPERIMENTAL SETUP... 3 IR SENSOR ARDUINO CODE... 4 ARDUINO IDE SERIAL MONITOR... 5 GAS SENSOR... 6 OVERVIEW...
More informationIntroduction to Arduino
Introduction to Arduino Paco Abad May 20 th, 2011 WGM #21 Outline What is Arduino? Where to start Types Shields Alternatives Know your board Installing and using the IDE Digital output Serial communication
More informationIntroduction To Arduino
Introduction To Arduino What is Arduino? Hardware Boards / microcontrollers Shields Software Arduino IDE Simplified C Community Tutorials Forums Sample projects Arduino Uno Power: 5v (7-12v input) Digital
More informationSECOND EDITION. Arduino Cookbook. Michael Margolis O'REILLY- Tokyo. Farnham Koln Sebastopol. Cambridge. Beijing
SECOND EDITION Arduino Cookbook Michael Margolis Beijing Cambridge Farnham Koln Sebastopol O'REILLY- Tokyo Table of Contents Preface xi 1. Getting Started 1 1.1 Installing the Integrated Development Environment
More informationWorkshop Arduino English starters workshop 2
Workshop Arduino English starters workshop 2 We advice to finish part 1 of this workshop before following this one. There are a set of assignments in this workshop that can be taken individually. First
More informationEng.mohammed Albhaisi. Lab#3 : arduino to proteus simulation. for simulate Arduino program that you wrote you have to have these programs :
Lab#3 : arduino to proteus simulation for simulate Arduino program that you wrote you have to have these programs : 1-Arduino C 2-proteus 3- Virtual Serial Port Driver 4-Arduino library to proteus You
More informationCarl Peto. 10th August 2017 SWIFT FOR ARDUINO
Carl Peto 10th August 2017 SWIFT FOR ARDUINO ARDUINO Microcontrollers are a small, cheap, multi purpose IoT computer in a box, with built in interfaces in the package, all in one chip. They can be bought
More informationIntroduction to Microcontrollers Using Arduino. PhilRobotics
Introduction to Microcontrollers Using Arduino PhilRobotics Objectives Know what is a microcontroller Learn the capabilities of a microcontroller Understand how microcontroller execute instructions Objectives
More informationMore Arduino Programming
Introductory Medical Device Prototyping Arduino Part 2, http://saliterman.umn.edu/ Department of Biomedical Engineering, University of Minnesota More Arduino Programming Digital I/O (Read/Write) Analog
More informationArduino Part 2. Introductory Medical Device Prototyping
Introductory Medical Device Prototyping Arduino Part 2, http://saliterman.umn.edu/ Department of Biomedical Engineering, University of Minnesota More Arduino Programming Digital I/O (Read/Write) Analog
More informationArduino and Matlab for prototyping and manufacturing
Arduino and Matlab for prototyping and manufacturing Enrique Chacón Tanarro 11th - 15th December 2017 UBORA First Design School - Nairobi Enrique Chacón Tanarro e.chacon@upm.es Index 1. Arduino 2. Arduino
More informationLCD KeyPad Shield For Arduino SKU: DFR0009
LCD KeyPad Shield For Arduino SKU: DFR0009 1602 LCD Keypad Shield For Arduino Contents 1 Introduction 2 Specification 3 Pinout 4 Library Explanation o 4.1 Function Explanation 5 Tutorial o 5.1 Example
More informationARDUINO LEONARDO ETH Code: A000022
ARDUINO LEONARDO ETH Code: A000022 All the fun of a Leonardo, plus an Ethernet port to extend your project to the IoT world. You can control sensors and actuators via the internet as a client or server.
More informationIntel Galileo gen 2 Board
Intel Galileo gen 2 Board The Arduino Intel Galileo board is a microcontroller board based on the Intel Quark SoC X1000, a 32- bit Intel Pentium -class system on a chip (SoC). It is the first board based
More informationArduino Uno. Power & Interface. Arduino Part 1. Introductory Medical Device Prototyping. Digital I/O Pins. Reset Button. USB Interface.
Introductory Medical Device Prototyping Arduino Part 1, http://saliterman.umn.edu/ Department of Biomedical Engineering, University of Minnesota Arduino Uno Power & Interface Reset Button USB Interface
More informationArduino Uno Microcontroller Overview
Innovation Fellows Program Arduino Uno Microcontroller Overview, http://saliterman.umn.edu/ Department of Biomedical Engineering, University of Minnesota Arduino Uno Power & Interface Reset Button USB
More informationElectronic Brick Starter Kit
Electronic Brick Starter Kit Getting Started Guide v1.0 by Introduction Hello and thank you for purchasing the Electronic Brick Starter Pack from Little Bird Electronics. We hope that you will find learning
More informationDigital Pins and Constants
Lesson Lesson : Digital Pins and Constants Digital Pins and Constants The Big Idea: This lesson is the first step toward learning to connect the Arduino to its surrounding world. You will connect lights
More informationElectronics Single Board Computers
Electronics Single Board Computers Wilfrid Laurier University November 23, 2016 Single Board Computers Single Board Computers As electronic devices get smaller and more sophisticated, they often contain
More informationPhysics 364, Fall 2012, Lab #9 (Introduction to microprocessor programming with the Arduino) Lab for Monday, November 5
Physics 364, Fall 2012, Lab #9 (Introduction to microprocessor programming with the Arduino) Lab for Monday, November 5 Up until this point we have been working with discrete digital components. Every
More informationLaboratory 3 Working with the LCD shield and the interrupt system
Laboratory 3 Working with the LCD shield and the interrupt system 1. Working with the LCD shield The shields are PCBs (Printed Circuit Boards) that can be placed over the Arduino boards, extending their
More informationArduino Programming Part 6: LCD Panel Output
Arduino Programming Part 6: LCD Panel Output EAS 199B, Winter 2013 Gerald Recktenwald Portland State University gerry@me.pdx.edu Goals Use the 20x4 character LCD display for output Overview of assembly
More informationArduino Cookbook O'REILLY* Michael Margolis. Tokyo. Cambridge. Beijing. Farnham Koln Sebastopol
Arduino Cookbook Michael Margolis O'REILLY* Beijing Cambridge Farnham Koln Sebastopol Tokyo Table of Contents Preface xiii 1. Getting Started 1 1.1 Installing the Integrated Development Environment (IDE)
More informationAdapted from a lab originally written by Simon Hastings and Bill Ashmanskas
Physics 364 Arduino Lab 1 Adapted from a lab originally written by Simon Hastings and Bill Ashmanskas Vithayathil/Kroll Introduction Last revised: 2014-11-12 This lab introduces you to an electronic development
More informationIntroduction to Arduino. Wilson Wingston Sharon
Introduction to Arduino Wilson Wingston Sharon cto@workshopindia.com Physical computing Developing solutions that implement a software to interact with elements in the physical universe. 1. Sensors convert
More informationFunctions & First Class Function Values
Functions & First Class Function Values PLAI 1st ed Chapter 4, PLAI 2ed Chapter 5 The concept of a function is itself very close to substitution, and to our with form. Consider the following morph 1 {
More informationNote. The above image and many others are courtesy of - this is a wonderful resource for designing circuits.
Robotics and Electronics Unit 2. Arduino Objectives. Students will understand the basic characteristics of an Arduino Uno microcontroller. understand the basic structure of an Arduino program. know how
More informationTA0297 WEMOS D1 R2 WIFI ARDUINO DEVELOPMENT BOARD ESP8266
TA0297 WEMOS D1 R2 WIFI ARDUINO DEVELOPMENT BOARD ESP8266 Contents 1. Overview TA0297... 3 2. Getting started:... 3 2.1. What is WeMos D1 R2 Wifi Arduino Development Board?... 3 2.2. What is IDUINO UNO?...
More informationComputer Architectures
Implementing the door lock with Arduino Gábor Horváth 2017. február 24. Budapest associate professor BUTE Dept. Of Networked Systems and Services ghorvath@hit.bme.hu Outline Aim of the lecture: To show
More informationEEG 101L INTRODUCTION TO ENGINEERING EXPERIENCE
EEG 101L INTRODUCTION TO ENGINEERING EXPERIENCE LABORATORY 1: INTRODUCTION TO ARDUINO IDE AND PROGRAMMING DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING UNIVERSITY OF NEVADA, LAS VEGAS 1. FYS KIT COMPONENTS
More informationSWITCH 10 KILOHM RESISTOR 220 OHM RESISTOR POTENTIOMETER LCD SCREEN INGREDIENTS
11 SWITCH 10 KILOHM RESISTOR 220 OHM RESISTOR POTENTIOMETER LCD SCREEN INGREDIENTS 115 CRYSTAL BALL CREATE A CRYSTAL BALL TO TELL YOUR FUTURE Discover: LCD displays, switch/case statements, random() Time:
More informationDesigned & Developed By: Ms. Jasleen Kaur, PhD Scholar, CSE. Computer Science & Engineering Department
Design & Development of IOT application using Intel based Galileo Gen2 board A Practical Approach (Experimental Manual For B.Tech & M.Tech Students) For SoC and Embedded systems in association with Intel
More informationIntroduction to Arduino
Introduction to Arduino Mobile Computing, aa. 2016/2017 May 12, 2017 Daniele Ronzani - Ph.D student in Computer Science dronzani@math.unipd.it What are Microcontrollers Very small and simple computers
More informationFUNCTIONS USED IN CODING pinmode()
FUNCTIONS USED IN CODING pinmode() Configures the specified pin to behave either as an input or an output. See the description of digital pins for details on the functionality of the pins. As of Arduino
More informationUniversity of Portland EE 271 Electrical Circuits Laboratory. Experiment: Arduino
University of Portland EE 271 Electrical Circuits Laboratory Experiment: Arduino I. Objective The objective of this experiment is to learn how to use the Arduino microcontroller to monitor switches and
More informationSpecification. 1.Power Supply direct from Microcontroller Board. 2.The circuit can be used with Microcontroller Board such as Arduino UNO R3.
Part Number : Product Name : FK-FA1410 12-LED AND 3-BOTTON SHIELD This is the experimental board for receiving and transmitting data from the port of microcontroller. The function of FK-FA1401 is fundamental
More informationArduino Programming and Interfacing
Arduino Programming and Interfacing Stensat Group LLC, Copyright 2017 1 Robotic Arm Experimenters Kit 2 Legal Stuff Stensat Group LLC assumes no responsibility and/or liability for the use of the kit and
More informationPDF of this portion of workshop notes:
PDF of this portion of workshop notes: http://goo.gl/jfpeym Teaching Engineering Design with Student-Owned Digital and Analog Lab Equipment John B. Schneider Washington State University June 15, 2015 Overview
More informationBuilding your own special-purpose embedded system gadget.
Bare-duino Building your own special-purpose embedded system gadget. Saves a little money. You can configure the hardware exactly the way that you want. Plus, it s fun! bare-duino 1 Arduino Uno reset I/O
More informationBASIC Arduino. Part I
BASIC Arduino Part I Objectives Introduction to Arduino Build a 1-60MHz DDS VFO prototype, breadboard and write Sketches, with Buffer amps to be designed, and PCB Using your own laptop Go on to build other
More informationEP486 Microcontroller Applications
EP486 Microcontroller Applications Topic 6 Step & Servo Motors Joystick & Water Sensors Department of Engineering Physics University of Gaziantep Nov 2013 Sayfa 1 Step Motor http://en.wikipedia.org/wiki/stepper_motor
More informationIDUINO for maker s life. User Manual. For IDUINO Mega2560 Board(ST1026)
User Manual For IDUINO Mega2560 Board(ST1026) 1.Overview 1.1 what is Arduino? Arduino is an open-source prototyping platform based on easy-to-use hardware and software. Arduino boards are able to read
More informationSPLDuino Programming Guide
SPLDuino Programming Guide V01 http://www.helloapps.com http://helloapps.azurewebsites.net Mail: splduino@gmail.com HelloApps Co., Ltd. 1. Programming with SPLDuino 1.1 Programming with Arduino Sketch
More informationJunying Huang Fangjie Zhou. Smartphone Locker
Junying Huang Fangjie Zhou Smartphone Locker Motivation and Concept Smartphones are making our lives more and more convenient. In addition to some basic functions like making calls and sending messages,
More informationFIRE SENSOR ROBOT USING ATMEGA8L
PROJECT REPORT MICROCONTROLLER AND APPLICATIONS ECE 304 FIRE SENSOR ROBOT USING ATMEGA8L BY AKSHAY PATHAK (11BEC1104) SUBMITTED TO: PROF. VENKAT SUBRAMANIAN PRAKHAR SINGH (11BEC1108) PIYUSH BLAGGAN (11BEC1053)
More informationSchedule. Sanford Bernhardt, Sangster, Kumfer, Michalaka. 3:10-5:00 Workshop: Build a speedometer 5:15-7:30 Dinner and Symposium: Group 2
Schedule 8:00-11:00 Workshop: Arduino Fundamentals 11:00-12:00 Workshop: Build a follower robot 1:30-3:00 Symposium: Group 1 Sanford Bernhardt, Sangster, Kumfer, Michalaka 3:10-5:00 Workshop: Build a speedometer
More informationGUIDE TO SP STARTER SHIELD (V3.0)
OVERVIEW: The SP Starter shield provides a complete learning platform for beginners and newbies. The board is equipped with loads of sensors and components like relays, user button, LED, IR Remote and
More information#include <Keypad.h> int datasens; #define pinsens 11. const byte ROWS = 4; //four rows const byte COLS = 3; //three columns
#include int datasens; #define pinsens 11 const byte ROWS = 4; //four rows const byte COLS = 3; //three columns char keys[rows][cols] = '1','2','3', '4','5','6', '7','8','9', '*','0','#' ; byte
More information1.0 The System Architecture and Design Features
1.0 The System Architecture and Design Features Figure 1. System Architecture The overall guiding design philosophy behind the Data Capture and Logging System Architecture is to have a clean design that
More informationStenBOT Robot Kit. Stensat Group LLC, Copyright 2018
StenBOT Robot Kit 1 Stensat Group LLC, Copyright 2018 Legal Stuff Stensat Group LLC assumes no responsibility and/or liability for the use of the kit and documentation. There is a 90 day warranty for the
More informationArduino Programming. Arduino UNO & Innoesys Educational Shield
Arduino Programming Arduino UNO & Innoesys Educational Shield www.devobox.com Electronic Components & Prototyping Tools 79 Leandrou, 10443, Athens +30 210 51 55 513, info@devobox.com ARDUINO UNO... 3 INNOESYS
More informationGADTs. Wouter Swierstra. Advanced functional programming - Lecture 7. Faculty of Science Information and Computing Sciences
GADTs Advanced functional programming - Lecture 7 Wouter Swierstra 1 Today s lecture Generalized algebraic data types (GADTs) 2 A datatype data Tree a = Leaf Node (Tree a) a (Tree a) This definition introduces:
More informationLab 3 XBees and LCDs and Accelerometers, Oh My! Part 1: Wireless Communication Using XBee Modules and the Arduino
University of Pennsylvania Department of Electrical and Systems Engineering ESE 205 Electrical Circuits and Systems Laboratory I Lab 3 XBees and LCDs and Accelerometers, Oh My! Introduction: In the first
More informationIntroduction to Computers and C++ Programming p. 1 Computer Systems p. 2 Hardware p. 2 Software p. 7 High-Level Languages p. 8 Compilers p.
Introduction to Computers and C++ Programming p. 1 Computer Systems p. 2 Hardware p. 2 Software p. 7 High-Level Languages p. 8 Compilers p. 9 Self-Test Exercises p. 11 History Note p. 12 Programming and
More informationLaboratory 5 Communication Interfaces
Laboratory 5 Communication Interfaces Embedded electronics refers to the interconnection of circuits (micro-processors or other integrated circuits) with the goal of creating a unified system. In order
More informationTANGIBLE MEDIA & PHYSICAL COMPUTING MORE ARDUINO
TANGIBLE MEDIA & PHYSICAL COMPUTING MORE ARDUINO AGENDA RECAP ALGORITHMIC APPROACHES TIMERS RECAP: LAST WEEK WE DID: ARDUINO IDE INTRO MAKE SURE BOARD AND USB PORT SELECTED UPLOAD PROCESS COVERED DATATYPES
More informationOne Grove Base Shield board this allows you to connect various Grove units (below) to your Seeeduino board; Nine Grove Grove units, consisting of:
GROVE - Starter Kit V1.0b Introduction The Grove system is a modular, safe and easy to use group of items that allow you to minimise the effort required to get started with microcontroller-based experimentation
More informationLAMPIRAN I (LISTING PROGRAM)
LAMPIRAN I (LISTING PROGRAM) #include LiquidCrystal lcd(8, 9, 4, 5, 6, 7); const int numreadings = 10; int readings[numreadings]; // the readings from the analog input int readindex =
More informationGoal: We want to build an autonomous vehicle (robot)
Goal: We want to build an autonomous vehicle (robot) This means it will have to think for itself, its going to need a brain Our robot s brain will be a tiny computer called a microcontroller Specifically
More informationMicrocontrollers for Ham Radio
Microcontrollers for Ham Radio MARTIN BUEHRING - KB4MG MAT T PESCH KK4NLK TOM PERRY KN4LSE What is a Microcontroller? A micro-controller is a small computer on a single integrated circuit containing a
More informationARDUINO YÚN Code: A000008
ARDUINO YÚN Code: A000008 Arduino YÚN is the perfect board to use when designing connected devices and, more in general, Internet of Things projects. It combines the power of Linux with the ease of use
More informationGADTs. Wouter Swierstra and Alejandro Serrano. Advanced functional programming - Lecture 7. [Faculty of Science Information and Computing Sciences]
GADTs Advanced functional programming - Lecture 7 Wouter Swierstra and Alejandro Serrano 1 Today s lecture Generalized algebraic data types (GADTs) 2 A datatype data Tree a = Leaf Node (Tree a) a (Tree
More informationIME-100 Interdisciplinary Design and Manufacturing
IME-100 Interdisciplinary Design and Manufacturing Introduction Arduino and Programming Topics: 1. Introduction to Microprocessors/Microcontrollers 2. Introduction to Arduino 3. Arduino Programming Basics
More informationanalogwrite(); The analogwrite function writes an analog value (PWM wave) to a PWM-enabled pin.
analogwrite(); The analogwrite function writes an analog value (PWM wave) to a PWM-enabled pin. Syntax analogwrite(pin, value); For example: analogwrite(2, 255); or analogwrite(13, 0); Note: Capitalization
More informationAlessandra de Vitis. Arduino
Alessandra de Vitis Arduino Arduino types Alessandra de Vitis 2 Interfacing Interfacing represents the link between devices that operate with different physical quantities. Interface board or simply or
More informationArduinos without (much) programming
Arduinos without (much) programming A course for Itchen Valley Amateur Radio Club Brian G0UKB Jan-Feb 2016 What on earth is an Arduino? It's a microprocessor A single chip computer with built in timing
More informationRuby: Introduction, Basics
Ruby: Introduction, Basics Computer Science and Engineering College of Engineering The Ohio State University Lecture 3 Ruby vs Java: Similarities Imperative and object-oriented Classes and instances (ie
More informationLecture 6: Embedded Systems and Microcontrollers
Lecture 6: Embedded Systems and Microcontrollers Bo Wang Division of Information & Computing Technology Hamad Bin Khalifa University bwang@hbku.edu.qa 1 What is Embedded System? Embedded System = Computers
More informationWhat s inside the kit
What s inside the kit 1 set Jumper Wires 5 pcs Tact Switch 1 pc Photoresistor 1 pc 400 Points Breadboard 1 pc Potentiometer 1 pc LCD 5 pcs 5mm Red LED 5 pcs 5mm Green LED 5 pcs 5mm Yellow LED 30 pcs Resistors
More informationArduino 101 AN INTRODUCTION TO ARDUINO BY WOMEN IN ENGINEERING FT T I NA A ND AW E S O ME ME NTO R S
Arduino 101 AN INTRODUCTION TO ARDUINO BY WOMEN IN ENGINEERING FT T I NA A ND AW E S O ME ME NTO R S Overview Motivation Circuit Design and Arduino Architecture Projects Blink the LED Switch Night Lamp
More informationFreeduino USB 1.0. Arduino Compatible Development Board Starter Guide. 1. Overview
Freeduino USB 1.0 Arduino Compatible Development Board Starter Guide 1. Overview 1 Arduino is an open source embedded development platform consisting of a simple development board based on Atmel s AVR
More informationGADTs. Alejandro Serrano. AFP Summer School. [Faculty of Science Information and Computing Sciences]
GADTs AFP Summer School Alejandro Serrano 1 Today s lecture Generalized algebraic data types (GADTs) 2 A datatype data Tree a = Leaf Node (Tree a) a (Tree a) This definition introduces: 3 A datatype data
More informationArduino Smart Robot Car Kit User Guide
User Guide V1.0 04.2017 UCTRONIC Table of Contents 1. Introduction...3 2. Assembly...4 2.1 Arduino Uno R3...4 2.2 HC-SR04 Ultrasonic Sensor Module with Bracket / Holder...5 2.3 L293D Motor Drive Expansion
More informationWelcome to Apollo. For more information, please visit the website and select Apollo. Default Code
Welcome to Apollo For more information, please visit the website and select Apollo Arduino Pins Default Code D49 LED Digital Pins digitalwrite digitalread pinmode Analog Pins analogread digitalread D33
More informationLaboratory 1 Introduction to the Arduino boards
Laboratory 1 Introduction to the Arduino boards The set of Arduino development tools include µc (microcontroller) boards, accessories (peripheral modules, components etc.) and open source software tools
More informationIDUINO for maker s life. User Manual. For IDUINO development Board.
User Manual For IDUINO development Board 1.Overview 1.1 what is Arduino? Arduino is an open-source prototyping platform based on easy-to-use hardware and software. Arduino boards are able to read inputs
More informationDigital Design through. Arduino
Digital Design through 1 Arduino G V V Sharma Contents 1 Display Control through Hardware 2 1.1 Powering the Display.................................. 2 1.2 Controlling the Display.................................
More informationX Board V2 (SKU:DFR0162)
X Board V2 (SKU:DFR0162) X-Board V2, DFR0162 Contents 1 Introduction 2 Specifications 3 Pinouts 4 Tutorial 4.1 Requirements 4.2 Wiring Diagram 4.3 Sample code Introduction This is Version 2.0 of the X-board.
More informationOverview of Microcontroller and Embedded Systems
UNIT-III Overview of Microcontroller and Embedded Systems Embedded Hardware and Various Building Blocks: The basic hardware components of an embedded system shown in a block diagram in below figure. These
More information1. For every evaluation of a variable var, the variable is bound.
7 Types We ve seen how we can use interpreters to model the run-time behavior of programs. Now we d like to use the same technology to analyze or predict the behavior of programs without running them.
More informationROBOTLINKING THE POWER SUPPLY LEARNING KIT TUTORIAL
ROBOTLINKING THE POWER SUPPLY LEARNING KIT TUTORIAL 1 Preface About RobotLinking RobotLinking is a technology company focused on 3D Printer, Raspberry Pi and Arduino open source community development.
More informationAcademic Year Annexure I. 1. Project Title: Color sensor based multiple line follower robot with obstacle detection
Academic Year 2015-16 Annexure I 1. Project Title: Color sensor based multiple line follower robot with obstacle detection TABLE OF CONTENTS 1.1 Abstract 2-2 1.2 Motivation 3-3 1.3 Objective 3-3 2.1 Block
More informationInternal Report: Heterogeneous IoT Network: TRACK-IoT Plateform. System Architecture. Controller. Proposed by: Hakima Chaouchi
Internal Report: Heterogeneous IoT Network: TRACK-IoT Plateform Proposed by: Hakima Chaouchi Team: Hakima Chaouchi; Kevin Raymond, Oscar Botero, Abderahim Ait Wakrim, Thomas Bourgeau. The TrackIot platform
More informationARDUINO M0 PRO Code: A000111
ARDUINO M0 PRO Code: A000111 The Arduino M0 Pro is an Arduino M0 with a step by step debugger With the new Arduino M0 Pro board, the more creative individual will have the potential to create one s most
More informationMicrocontroller Basics
Microcontroller Basics Gabe Cohn CSE 599U February 6, 2012 www.gabeacohn.com/teaching/micro Outline Overview of Embedded Systems What is a Microcontroller? Microcontroller Features Common Microcontrollers
More informationProcedure: Determine the polarity of the LED. Use the following image to help:
Section 2: Lab Activity Section 2.1 Getting started: LED Blink Purpose: To understand how to upload a program to the Arduino and to understand the function of each line of code in a simple program. This
More information