Location via proxy:
[ UP ]
[Report a bug]
[Manage cookies]
No cookies
No scripts
No ads
No referrer
Show this form
Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Building Your Own Lightsaber
Search
Pete Hodgson
January 03, 2014
Programming
103
6.1k
Building Your Own Lightsaber
Presented at CodeMash 2014
Pete Hodgson
January 03, 2014
Tweet
Share
More Decks by Pete Hodgson
See All by Pete Hodgson
Migratory Patterns - KubeCon Salt Lake City, 2024
phodgson
0
14
A Journey Into Feature Toggles - OSCON Austin 2017
phodgson
5
510
Test-driven Client-side JS
phodgson
5
770
Functional Reactive JavaScript
phodgson
8
730
different.js - Forward JS 2014
phodgson
4
770
Railsconf2014
phodgson
7
1.4k
iOS Unit Testing Workshop
phodgson
3
460
Multi-platform Mobile with Calatrava - May 2013
phodgson
2
430
Unit testing with Kiwi - CocoaConf San Jose 2013
phodgson
1
580
Other Decks in Programming
See All in Programming
『ドメイン駆動設計をはじめよう』のモデリングアプローチ
masuda220
PRO
8
520
弊社の「意識チョット低いアーキテクチャ」10選
texmeijin
5
24k
Boost Performance and Developer Productivity with Jakarta EE 11
ivargrimstad
0
1.8k
Nurturing OpenJDK distribution: Eclipse Temurin Success History and plan
ivargrimstad
0
710
シールドクラスをはじめよう / Getting Started with Sealed Classes
mackey0225
3
450
「今のプロジェクトいろいろ大変なんですよ、app/services とかもあって……」/After Kaigi on Rails 2024 LT Night
junk0612
5
2.1k
Enabling DevOps and Team Topologies Through Architecture: Architecting for Fast Flow
cer
PRO
0
270
推し活の ハイトラフィックに立ち向かう Railsとアーキテクチャ - Kaigi on Rails 2024
falcon8823
6
2.8k
【Kaigi on Rails 2024】YOUTRUST スポンサーLT
krpk1900
1
320
Jakarta Concurrencyによる並行処理プログラミングの始め方 (JJUG CCC 2024 Fall)
tnagao7
1
280
3rd party scriptでもReactを使いたい! Preact + Reactのハイブリッド開発
righttouch
PRO
1
600
外部システム連携先が10を超えるシステムでのアーキテクチャ設計・実装事例
kiwasaki
1
290
Featured
See All Featured
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
The Language of Interfaces
destraynor
154
24k
GitHub's CSS Performance
jonrohan
1030
460k
Product Roadmaps are Hard
iamctodd
PRO
49
11k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
7
630
Intergalactic Javascript Robots from Outer Space
tanoku
269
27k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
A Tale of Four Properties
chriscoyier
156
23k
Embracing the Ebb and Flow
colly
84
4.5k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
Transcript
Building your own Lightsaber
me me me Pete Hodgson Consultant at ThoughtWorks @ph1 blog.thepete.net
TSA Pro-Tip™
None
None
Green Field http://www.flickr.com/photos/jillclardy/3213748255
Continuous Integration
Feedback
None
Feedback
http://www.flickr.com/photos/johnmueller/52621490/ what if you have no build box?
None
Raspberry Pi
None
Raspberry Pi
visual indicator aka build light
None
None
Build Light
Pretending to work
raspberry pi & build light
done.
done. ?
build light build my own lightsaber
Learning by Doing
Learning Doing
Learning Doing Learning By Doing
Choose a “right-sized“ problem
build light build my own lightsaber
LEDs low voltage (can be powered via USB) bright flexible
(blinky! colors!)
all the colors
The Drefus Model
Beginner Expert
Beginner detailed step-by-step instructions no wider context
Beginner detailed step-by-step instructions no wider context Expert wider context
(goal) no details (yet)
Know where you are on the Drefus scale
None
all the colors
multi-color LEDs Search
multi-color LEDs Search an LED can only be one color…
but LEDs can come in many colors… solution: combine different colored LEDs
RGB color mixing
vary LED brightness Search
vary LED brightness Pulse Width Modulation P W M Search
Incandescent Bulb Voltage Brightness
LED Voltage Brightness
voltage 100% 0% time brightness: 100%
voltage 100% 0% time
50% on 50% off duty cycle voltage 100% 0% time
50% on 50% off duty cycle brightness: 50% voltage 100%
0% time
voltage 100% 0% time
25% on 75% off voltage 100% 0% time
brightness: 25% 25% on 75% off voltage 100% 0% time
Don't trust your intuition '
Red LED + Green LED + Blue LED + PWM
= all the colors!
None
Raspberry PI red LED green LED blue LED PWM
GPIO Pins
Raspberry Pi has two GPIO pins which capable of PWM
output. Our light needs three.
Arduino
Arduino is an Open-Source electronics prototyping platform based on flexible,
easy-to-use hardware and software. - arduino.cc
Arduino
Raspberry PI red LED green LED blue LED PWM
Raspberry PI red LED green LED blue LED PWM Arduino
???
Feature-creep as a learning tool
Raspberry PI red LED green LED blue LED PWM Arduino
???
None
baby steps, towards an eventual goal.
sketch 1 blinking an LED (Hello World of hardware)
None
IO pin ground pin
None
pin “high” (+ve voltage)
pin “low” (0 voltage)
int LED_PIN = 6;! ! void setup() { ! pinMode(LED_PIN,
OUTPUT); ! }! ! void loop() {! digitalWrite(LED_PIN, HIGH);! delay(1000); ! digitalWrite(LED_PIN, LOW);! delay(1000); ! }!
sketch 2 fading an LED (PWM)
None
int LED_PIN = 6;! int MAX_BRIGHTNESS = 255;! int brightness
= 0;! ! void setup() { ! pinMode(LED_PIN, OUTPUT); ! }! ! void loop() {! analogWrite(LED_PIN, brightness);! ! brightness = brightness + 5;! if( brightness > MAX_BRIGHTNESS )! brightness = 0;! ! delay(30);! }!
int LED_PIN = 6;! int MAX_BRIGHTNESS = 255;! int brightness
= 0;! ! void setup() { ! pinMode(LED_PIN, OUTPUT); ! }! ! void loop() {! analogWrite(LED_PIN, brightness);! ! brightness = brightness + 5;! if( brightness > MAX_BRIGHTNESS )! brightness = 0;! ! delay(30);! }! PWM
sketch 3 mixing colors
None
None
None
int RED_PIN = 3;! int GREEN_PIN = 5;! int BLUE_PIN
= 6;! int MAX_BRIGHTNESS = 255;! ! void setup() { ! pinMode(RED_PIN, OUTPUT );! pinMode(GREEN_PIN, OUTPUT );! pinMode(BLUE_PIN, OUTPUT );! }! ! void loop() {! byte color[3];! assignRandomColorTo(color);! displayColor(color);! delay(1000); ! }! ! void assignRandomColorTo(byte colorComponents[]){! colorComponents[0] = random(MAX_BRIGHTNESS);!
int RED_PIN = 3;! int GREEN_PIN = 5;! int BLUE_PIN
= 6;! int MAX_BRIGHTNESS = 255;! ! void setup() { ! pinMode(RED_PIN, OUTPUT );! pinMode(GREEN_PIN, OUTPUT );! pinMode(BLUE_PIN, OUTPUT );! }! ! void loop() {! byte color[3];! assignRandomColorTo(color);! displayColor(color);! delay(1000); ! }! ! void assignRandomColorTo(byte colorComponents[]){! colorComponents[0] = random(MAX_BRIGHTNESS);!
int RED_PIN = 3;! int GREEN_PIN = 5;! int BLUE_PIN
= 6;! int MAX_BRIGHTNESS = 255;! ! void setup() { ! pinMode(RED_PIN, OUTPUT );! pinMode(GREEN_PIN, OUTPUT );! pinMode(BLUE_PIN, OUTPUT );! }! ! void loop() {! byte color[3];! assignRandomColorTo(color);! displayColor(color);! delay(1000); ! }! ! void assignRandomColorTo(byte colorComponents[]){! colorComponents[0] = random(MAX_BRIGHTNESS);!
! void loop() {! byte color[3];! assignRandomColorTo(color);! displayColor(color);! delay(1000); !
}! ! void assignRandomColorTo(byte colorComponents[]){! colorComponents[0] = random(MAX_BRIGHTNESS);! colorComponents[1] = random(MAX_BRIGHTNESS);! colorComponents[2] = random(MAX_BRIGHTNESS);! }! ! void displayColor(byte colorComponents[]){! analogWrite( RED_PIN, colorComponents[0] );! analogWrite( GREEN_PIN, colorComponents[1] );! analogWrite( BLUE_PIN, colorComponents[2] ); ! }!
! void loop() {! byte color[3];! assignRandomColorTo(color);! displayColor(color);! delay(1000); !
}! ! void assignRandomColorTo(byte colorComponents[]){! colorComponents[0] = random(MAX_BRIGHTNESS);! colorComponents[1] = random(MAX_BRIGHTNESS);! colorComponents[2] = random(MAX_BRIGHTNESS);! }! ! void displayColor(byte colorComponents[]){! analogWrite( RED_PIN, colorComponents[0] );! analogWrite( GREEN_PIN, colorComponents[1] );! analogWrite( BLUE_PIN, colorComponents[2] ); ! }!
! void loop() {! byte color[3];! assignRandomColorTo(color);! displayColor(color);! delay(1000); !
}! ! void assignRandomColorTo(byte colorComponents[]){! colorComponents[0] = random(MAX_BRIGHTNESS);! colorComponents[1] = random(MAX_BRIGHTNESS);! colorComponents[2] = random(MAX_BRIGHTNESS);! }! ! void displayColor(byte colorComponents[]){! analogWrite( RED_PIN, colorComponents[0] );! analogWrite( GREEN_PIN, colorComponents[1] );! analogWrite( BLUE_PIN, colorComponents[2] ); ! }!
! void loop() {! byte color[3];! assignRandomColorTo(color);! displayColor(color);! delay(1000); !
}! ! void assignRandomColorTo(byte colorComponents[]){! colorComponents[0] = random(MAX_BRIGHTNESS);! colorComponents[1] = random(MAX_BRIGHTNESS);! colorComponents[2] = random(MAX_BRIGHTNESS);! }! ! void displayColor(byte colorComponents[]){! analogWrite( RED_PIN, colorComponents[0] );! analogWrite( GREEN_PIN, colorComponents[1] );! analogWrite( BLUE_PIN, colorComponents[2] ); ! }!
Raspberry PI red LED green LED blue LED PWM Arduino
???
Raspberry PI red LED green LED blue LED PWM Arduino
???
Raspberry PI red LED green LED blue LED PWM Arduino
serial
sketch 4 an echo server (serial IO)
void setup()! {! Serial.begin(57600); // start serial port at 57600
bps! }! ! void loop() {! waitForInput();! ! static char input[1025];! int bytesRead = Serial.readBytesUntil( '\n', input, 1024 );! ! if( bytesRead ){! String str = String(input);! str.toUpperCase();! Serial.println(str);! }! }! ! void waitForInput() {! while (Serial.available() <= 0) {! // busy loop! }! }!
void setup()! {! Serial.begin(57600); // start serial port at 57600
bps! }! ! void loop() {! waitForInput();! ! static char input[1025];! int bytesRead = Serial.readBytesUntil( '\n', input, 1024 );! ! if( bytesRead ){! String str = String(input);! str.toUpperCase();! Serial.println(str);! }! }! ! void waitForInput() {! while (Serial.available() <= 0) {! // busy loop! }! }!
void setup()! {! Serial.begin(57600); // start serial port at 57600
bps! }! ! void loop() {! waitForInput();! ! static char input[1025];! int bytesRead = Serial.readBytesUntil( '\n', input, 1024 );! ! if( bytesRead ){! String str = String(input);! str.toUpperCase();! Serial.println(str);! }! }! ! void waitForInput() {! while (Serial.available() <= 0) {! // busy loop! }! }!
void setup()! {! Serial.begin(57600); // start serial port at 57600
bps! }! ! void loop() {! waitForInput();! ! static char input[1025];! int bytesRead = Serial.readBytesUntil( '\n', input, 1024 );! ! if( bytesRead ){! String str = String(input);! str.toUpperCase();! Serial.println(str);! }! }! ! void waitForInput() {! while (Serial.available() <= 0) {! // busy loop! }! }!
void setup()! {! Serial.begin(57600); // start serial port at 57600
bps! }! ! void loop() {! waitForInput();! ! static char input[1025];! int bytesRead = Serial.readBytesUntil( '\n', input, 1024 );! ! if( bytesRead ){! String str = String(input);! str.toUpperCase();! Serial.println(str);! }! }! ! void waitForInput() {! while (Serial.available() <= 0) {! // busy loop! }! }!
void setup()! {! Serial.begin(57600); // start serial port at 57600
bps! }! ! void loop() {! waitForInput();! ! static char input[1025];! int bytesRead = Serial.readBytesUntil( '\n', input, 1024 );! ! if( bytesRead ){! String str = String(input);! str.toUpperCase();! Serial.println(str);! }! }! ! void waitForInput() {! while (Serial.available() <= 0) {! // busy loop! }! }!
Raspberry PI red LED green LED blue LED PWM Arduino
serial
GPIO Pins
Raspberry PI red LED green LED blue LED Arduino
Raspberry PI red LED green LED blue LED Arduino “ffaa11\n”
Raspberry PI red LED green LED blue LED Arduino “ffaa11\n”
Raspberry PI red LED green LED blue LED Arduino “ffaa11\n”
Much Learning Arduino- compatibles bareduinos LPC810 soldering! transistors protoboard fritzing
voltage regulators node.js cctray line-level converters command-line builds C++ on Arduino usb to serial external programmers OSS hardware
Resources
Resources
moredip/aphex (work in progress)
Have FUN!
Pete Hodgson @ph1
[email protected]
these slides http://bit.ly/buildlightsaber