7. Javascript on Arduino
Motivation
SainSmart palletizing
robotic arm - $118.23
Pros
● Much cheaper than rival
hobby robotic arms
● Performs surprisingly well
in terms of speed
11. Javascript on Arduino
Motivation
IoT is the buzzword of the day
But it isn't entirely new
● Parts are cheaper
● Tutorials are available
● Technology is more developer friendly
● Similar reasons why many people became
software developers
● We will get back to this
12. Javascript on Arduino
Arduino
- Is a microcontroller (Open source prototyping platform) – A small
computer on a single integrated circuit (memory, processor, I/O peripherals).
- One of several competing products
Shield
- Extends capabilities of the Arduino
- Requires a driver
- Requires soldering
13. Javascript on Arduino
Javascript is powering devices
● Johnny-five http://johnny-five.io
● Cylon http://cylonjs.com
● Espruino (Javascript on the metal) http://www.espruino.com/
● and more!
15. Javascript on Arduino
Javascript is powering devices
Firmata: It's a protocol, it's a library...
- Enables communication between a
computer and a microcontroller using the
midi message format:
http://www.midi.org/techspecs/midimessages.php
18. Javascript on Arduino
Software:
johnny-five: JS Robotics & IoT framework
compulsive ('13) – Loops and delays without traditional
timers. Time based event loop process queue
temporal? (TODO '14) – Non-blocking, temporal task
sequencing.
Javascript is powering devices
19. Javascript on Arduino
johnny-five
- has a useful REPL
(read-eval-print loop)
- supports a growing number of
boards, shields, sensors,
actuators
Javascript is powering devices
20. Javascript on Arduino
Hardware: Arduino Mega 2560
AdaFruit Servo Shield
Servos
IR motion sensor
Javascript is powering devices
21. Javascript on Arduino
Hardware: Load Sensor
HX711 Load Cell Amp
MultiColor Led
HUZZA ESP8266 Wifi breakout
Javascript is powering devices
22. Javascript on Arduino
Powered by:
Arduino: Basic arm motion only
(4) 1.5V AA Batteries: Arm with augmented body
5V 2A power supply: Arm, lid, motion sensor. Struggles lifting
when all 3 in operation at the same time.
5V 10A power supply: Sufficient
Servos require lots of power!
23. Javascript on Arduino
Be careful about mishaps. The larger/stronger the robot, the
more severe the accident.
Accidents can quickly disable functionality.
Servos require lots of power!
24. Javascript on Arduino
Be careful about mishaps. The larger/stronger the robot, the
more severe the accident.
Accidents can quickly disable functionality.
Recovery may take several days (new hardware in the mail)
Servos require lots of power!
25. Javascript on Arduino
Be careful about mishaps. The larger/stronger the robot, the
more severe the accident.
Accidents can quickly disable functionality.
Recovery may take several days (new hardware in the mail)
+ Add an emergency stop early
Servos require lots of power!
26. Javascript on Arduino
When composition relies heavily on found
components, and the idea is ad hoc, hardware
refactoring/reassembly is frequent.
Lesson: It's easy to end up in
the weeds
27. Javascript on Arduino
When composition relies heavily on found
components, and the idea is ad hoc, hardware
refactoring/reassembly is frequent.
+ Plan well, measure accurately and thoroughly.
Lesson: It's easy to end up in
the weeds
28. Javascript on Arduino
When composition relies heavily on found
components, and the idea is ad hoc, hardware
refactoring/reassembly is frequent.
+ Plan well, measure accurately and thoroughly.
+ Expect to spend considerable time refactoring if you
are planning as you go.
Lesson: It's easy to end up in
the weeds
29. Javascript on Arduino
+ Refactor small, iterative/incremental, stable as possible
Lesson: It's easy to end up in
the weeds
30. Javascript on Arduino
+ Refactor small, iterative/incremental, stable as possible
+ Use a board to track tasks
Lesson: It's easy to end up in
the weeds
31. Javascript on Arduino
+ Refactor small, iterative/incremental, stable as possible
+ Use a board to track tasks
+ Keep changes in sync with the REPL
Lesson: It's easy to end up in
the weeds
32. Javascript on Arduino
Couples sensory information to action selection (what to do next)
in an intimate bottom-up fashion.
Subsumption Architecture
33. Javascript on Arduino
Subsumption Architecture
Couples sensory information to action selection (what to do next)
in an intimate bottom-up fashion.
Behaviors prioritized and interruptive.
34. Javascript on Arduino
Subsumption Architecture
Couples sensory information to action selection (what to do next)
in an intimate bottom-up fashion.
Behaviors prioritized and interruptive.
Lejos: Robot accessed directly through behaviors, focus on
looping actions broken by flipping a boolean to false. Static
methods/fields for convenience
35. Javascript on Arduino
Couples sensory information to action selection (what to do next)
in an intimate bottom-up fashion.
Behaviors prioritized and interruptive.
Lejos: Robot accessed directly through behaviors, focus on
looping actions broken by flipping a boolean to false. Static
methods/fields for convenience
Challenge: Action selection implementation
Subsumption Architecture
40. Javascript on Arduino
- Costly,
prohibitive
ramp-up time
● Inexpensive,
interoperable, plug-and-
play components
● Expensive computation
occurs in the cloud
● The only limitation is
creativity
45. Javascript on Arduino
- Detects presence of cat
-Waits for cat to do its business
-Warns off nearby cat(s)
46. Javascript on Arduino
- Detects presence of cat
-Waits for cat to do its business
-Warns off nearby cat(s)
-Scoops the clumps, deposits
them in bin
47. Javascript on Arduino
- Detects presence of cat
-Waits for cat to do its business
-Warns off nearby cat(s)
-Scoops the clumps, deposits
them in bin
- Levels the mounds
48. Javascript on Arduino
- Detects presence of cat
-Waits for cat to do its business
-Warns off nearby cat(s)
-Scoops the clumps, deposits
them in bin
- Levels the mounds
(v2) Tracks litter level in bin
(v2) Notifies user once bin is full
(v2) Detects clumps
(v2) Wireless