candies for everybody: hacking from 9 to 6

Post on 25-Jul-2015

261 Views

Category:

Technology

2 Downloads

Preview:

Click to see full reader

TRANSCRIPT

@YourTwitterHandle#Voxxed

Candies for everybody: hacking from 9 to 6

Alberto López Braintree_Dev.

Candies for everybody: hacking from 9 to 6

Alberto López Braintree_Dev.

<Advocate/>

https://flic.kr/p/6kFQBc

#Voxxed

@Braintree_Dev

@AlbertusLM

>who am I?_

@PayPalDev @AlbertusLM@AlbertusLM@Braintree_Dev#Voxxed

@AlbertusLM@Braintree_Dev#Voxxed

@AlbertusLM@Braintree_Dev#Voxxed

2015.battlehack.org

My Office

@AlbertusLM@Braintree_Dev#Voxxed

@AlbertusLM@Braintree_Dev#Voxxed

I <3 hacking from 9 to 6

>how is our world?_

@AlbertusLM@Braintree_Dev#Voxxed

Our breakfast

@AlbertusLM@Braintree_Dev#Voxxed

Our plants

deportes

@AlbertusLM@Braintree_Dev#Voxxed

Our sports

@AlbertusLM@Braintree_Dev#Voxxed

Our watches

@AlbertusLM@Braintree_Dev#Voxxed

Our cars

>how could be our real world?_

@AlbertusLM@Braintree_Dev#Voxxed

Our breakfast

@AlbertusLM@Braintree_Dev#Voxxed

Our plants

@AlbertusLM@Braintree_Dev#Voxxed

Our sports

@AlbertusLM@Braintree_Dev#Voxxed

Our watches

@AlbertusLM@Braintree_Dev#Voxxed

Our cars

welcome…

to the present!

@AlbertusLM@Braintree_Dev#Voxxed

@AlbertusLM@Braintree_Dev#Voxxed

"In the next century, planet earth will don an electronic skin."

Neil Gross, 1999

>levers of innovation_

@AlbertusLM@Braintree_Dev#Voxxed

technology

@AlbertusLM@Braintree_Dev#Voxxed

new business models

@AlbertusLM@Braintree_Dev#Voxxed

meet new needs

@AlbertusLM@Braintree_Dev#Voxxed

DIY trend

@AlbertusLM@Braintree_Dev#Voxxed

new ways to learn

@AlbertusLM@Braintree_Dev#Voxxed

movement to open source

>internet of things_everything

Disney Effect

@AlbertusLM@Braintree_Dev#Voxxed

@AlbertusLM@Braintree_Dev#Voxxed

@AlbertusLM@Braintree_Dev#Voxxed

>Introducing: The Hype Cicle_gartner.com/newsroom/id/2819918 (2014)

@AlbertusLM@Braintree_Dev#Voxxed

@AlbertusLM@Braintree_Dev#Voxxed

@AlbertusLM@Braintree_Dev#Voxxed

@AlbertusLM@Braintree_Dev#Voxxed

@AlbertusLM@Braintree_Dev#Voxxed

4.9 Billion Connected "Things" by 2015

http://www.gartner.com/newsroom/id/2905717

Gartner Symposium/ITxpo 2014, November 9-13 in Barcelona, Spain

@AlbertusLM@Braintree_Dev#Voxxed

25 Billion Connected “Things" by 2020

http://www.gartner.com/newsroom/id/2905717

Gartner Symposium/ITxpo 2014, November 9-13 in Barcelona, Spain

different point of views

Different points of view

>popular IoT devices

@AlbertusLM@Braintree_Dev#Voxxed

Raspberry Pi

@AlbertusLM@Braintree_Dev#Voxxed

Arduino Yún

@AlbertusLM@Braintree_Dev#Voxxed

Intel Galileo

@AlbertusLM@Braintree_Dev#Voxxed

Spark Core

@AlbertusLM@Braintree_Dev#Voxxed

Weareable devices

Flora Wearable Electronic Platform

Gemma Tiny Sewable Microcontroller

@AlbertusLM@Braintree_Dev#Voxxed

I <3 them

@AlbertusLM@Braintree_Dev#Voxxed

I <3 hacking from 9 to 6

>and what about BT_Dev Team?_

@AlbertusLM@Braintree_Dev#Voxxed

best way to learn is teach

@AlbertusLM@Braintree_Dev#Voxxed

try, fail, success

@AlbertusLM@Braintree_Dev#Voxxed

amazing projects

@AlbertusLM@Braintree_Dev#Voxxed

everything handy to everyone

@AlbertusLM@Braintree_Dev#Voxxed

We <3 hack from 9 to 6

>study case: Candy Machine_

@AlbertusLM@Braintree_Dev#Voxxed

common candy machine

digital sensor

4 bateries AA

low level core

@AlbertusLM@Braintree_Dev#Voxxed

The Candy Machine 2.0

tft screen

4 bateries AA & USB cable

spark core

connected to the Internet

@AlbertusLM@Braintree_Dev#Voxxed

target

learn about Internet of Things

learn how Spark core works

refresh C&C++

learn python & django

integrate v.zero SDK

demo online & offline

@AlbertusLM@Braintree_Dev#Voxxed

features

Internet connected

shows on the screen the tweet name

shows on the screen the transaction id

delivers candies after payment on a

website

mobilized website: candymachine.ngrok.com

@AlbertusLM@Braintree_Dev#Voxxed

hardware

generic candy machine (r.ebay.com/CBVghK)

spark core (spark.io)

2.2” TFT with SD (goo.gl/lDS3FH)

CC motor 5V (goo.gl/zLjKL4)

generic SD 1GB

@AlbertusLM@Braintree_Dev#Voxxed

Braintree v.zero SDK

<frontend> <backend>

@AlbertusLM@Braintree_Dev#Voxxed

server

django v.1.7.1 (djangoproject.com)

ngrok (ngrok.com)

braintree v.zero SDK (developers.braintreepayments.com)

tweetpony API (pypi.python.org/pypi/TweetPony)

spyrk API (pypi.python.org/pypi/spyrk)

@AlbertusLM@Braintree_Dev#Voxxed

spark core

ILI9341 for Spark (github.com/pkourany/ILI9341_SPI_LCD)

SD library for Spark (github.com/technobly/SparkCore-SD)

@AlbertusLM@Braintree_Dev#Voxxed

@AlbertusLM@Braintree_Dev#Voxxed

github.com/albertuslm/CandyMachine

@AlbertusLM@Braintree_Dev#Voxxed

1. home

nothing interesting to show.

it’s only a template!

< server />

[…] <script src=“https://js.braintreegateway.com/v2/braintree.js"> </script> </head> <body> […] <form id="paymentForm" action="/checkout" method="post"> <div class="content"> <label for="twitterName">Twitter Alias (optional)</label> <input type="text" id="twitter" name="twitter"> </div> <div id="container"> </div> <input type="submit" value="Pay $1 USD"> </form> […] <script> braintree.setup("{{client_token}}","dropin",{ container:"container" }) </script> </body>

@AlbertusLM@Braintree_Dev#Voxxed

2. payment page

< server : frontend />

Calling to Braintree to create v.zero form

@AlbertusLM@Braintree_Dev#Voxxed

< server : backend />

2. payment page

import braintree

[…]

braintree.Configuration.configure( braintree.Environment.Sandbox, merchant_id=“<BT merchant id>", public_key="<BT public key>", private_key="<BT private key>" )

[…]

def payment(request):

client_token=braintree.ClientToken.generate({})

return render_to_response("payment.html",locals())

Asking for client token to create v.zero form

@AlbertusLM@Braintree_Dev#Voxxed

3. checkout page[…] braintree.Configuration.configure([…])

spark = SparkCloud(USERNAME, PASSWORD)

[…]

def checkout(request): nonce=request.POST.get("payment_method_nonce")

result=braintree.Transaction.sale({ "amount":"1.00", "payment_method_nonce":nonce })

transaction_id=result.transaction.id

[…] spark.albertusLM_core.twitter(twitterName)

api = tweetpony.API() api.update_status(text)

[…]

spark.albertusLM_core.candy(transaction_id)

< server : backend />

finishing the transaction

sending info to spark

@AlbertusLM@Braintree_Dev#Voxxed

< server : frontend />

3. checkout page

<body>

[…]

<h3>Payment Completed</h3>

<p><b>Transaction ID:</b>{{transaction_id}}</p>

[…]

</body>

@AlbertusLM@Braintree_Dev#Voxxed

1. setup

< spark core />

#define SD_CS A6 #define TFT_CS A2 #define TFT_RST A0 #define TFT_DC A1 #define MOTOR D0 #define BUFFPIXEL 20

Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);

void setup() […] tft.begin();

testFillScreen(); SD.begin(SD_CS);

pinMode(MOTOR, OUTPUT);

setScreenToStandBy();

Spark.function("twitter", tftShowTwitter);

Spark.function("candy", moveMotorCandy);

@AlbertusLM@Braintree_Dev#Voxxed

2. show Twitter image

< spark core />

int tftShowTwitter(String command) { //Adjustment to present correctly the text on the screen String textToPrint = " Sending tweet to \n" " "+ command;

//Printing the Twitter screen bmpDraw("twitter.bmp", 0, 0); showTextInScreen(textToPrint,10,140); delay(4000); }

Sending  tweet  to  albertusLM

@AlbertusLM@Braintree_Dev#Voxxed

3. move motor and show transaction

< spark core />

int moveMotorCandy(String command) { //Adjustment to present correctly the text on the screen String textToPrint = " Enjoy! \n" " Tr.ID: "+ command;

//Printing the MotorMovement screen bmpDraw("motor.bmp", 0, 0); showTextInScreen (textToPrint,10,160); delay(1000);

digitalWrite(MOTOR, 1); // Turn ON the motor delay(milisecsMovingMotor); digitalWrite(MOTOR, 0); // Turn OFF the motor

delay(3000); setScreenToStandBy(); }

Enjoy!  Tr.ID:  dfr43

@AlbertusLM@Braintree_Dev#Voxxed

dem

@AlbertusLM@Braintree_Dev#Voxxed

dem

connect to candymachine.ngrok.com

follow the instructions to write the CC

enjoy your candies!

backup plan:

video J

@AlbertusLM@Braintree_Dev#Voxxed

>conclussions_

internet of things tendencia

Year of Internet of Things

goo.gl/ixjlaa

@AlbertusLM@Braintree_Dev#Voxxed

u <3 hack?

Alberto López alberto.lopez@getbraintree.com

@AlbertusLM / @Braintree_Dev

top related