Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 9: Programming Beans Topics: Bean Android SDK Date: Mar 29, 2016.

Similar presentations


Presentation on theme: "Lecture 9: Programming Beans Topics: Bean Android SDK Date: Mar 29, 2016."— Presentation transcript:

1 Lecture 9: Programming Beans Topics: Bean Android SDK Date: Mar 29, 2016

2 References (study these) https://punchthrough.com/bean/guides/features/accelerometer/ https://github.com/PunchThrough/bean-sdk-android https://github.com/nirjon/Beanocular

3 We will use a ‘Bean’ https://punchthrough.com/bean/guides/everything-else/free-bean/ To get a Bean for free:

4 Installation/Setup Coding: Install Arduino + Bean IDE Patch (for laptop) Install DroidEdit App (coding on the phone!) Loading/Running Code on Bean: Install BeanLoader App (Phone or Laptop) https://punchthrough.com/bean/guides/everything-else/downloads/

5 Coding and Loading: Way #1 Coding + Wireless loading Arduino studio + Bean patch + Beanloader (laptop)

6 Coding and Loading: Way #2 Wireless Loading Arduino studio + Bean Patch Android BeanLoader App File Copy

7 Coding and Loading: Way #3 Wireless Loading Android BeanLoader App File Select DroidEdit App

8 Let’s see BeanLoader in action

9 Programming: Bean + Android Write code for Arduino Write code for Android (need new lib) BLE

10 Code for Arduino Write code: Read Acceleration Send over Serial void setup() { Serial.begin(57600); } void loop() { AccelerationReading reading = Bean.getAcceleration(); char x = abs(reading.xAxis) / 2; char y = abs(reading.yAxis) / 2; char z = abs(reading.zAxis) / 2; Bean.setLed(x, y, z); Serial.println(x); //Serial.println(y); //Serial.println(z); }

11 Code for Android Setup Android Project: /app/build.grade (dependencies) /app/build.grade (defaultConfig) AndroidManifest.xml Permissions compile 'com.punchthrough.bean.sdk:sdk:1.0.1' https://github.com/PunchThrough/bean-sdk-android minSdkVersion 18 targetSdkVersion 22

12 Code for Android Bean Discovery Listener: BeanManager.getInstance().startDiscovery(bdl); BeanDiscoveryListener bdl = new BeanDiscoveryListener() { @Override public void onBeanDiscovered(Bean bean, int rssi) { Log.v("NIRJON", "" + bean.getDevice() + ", " + rssi); b = bean; // Bean b was declared in Activity. } @Override public void onDiscoveryComplete() { } };

13 Code for Android Bean Listener: b.connect(getBaseContext(), blsnr); BeanListener blsnr = new BeanListener() { @Override public void onConnected() { Log.v("NIRJON", "Bean is connected!!!"); } //several other auto generated functions }

14 Code for Android Bean Reading Acceleration: b.readAcceleration(new Callback () { @Override public void onResult(Acceleration result) { Log.v("NIRJON", "" + result.x() + ", " + result.y() + ", " + result.z()); } });

15 DIY and Remarks 1 Bean per group Install BeanLoader App and RENAME bean Test today’s Android code with your Bean Handle the Bean with care Do not keep the battery ON Do not lose the Bean, battery, plastic, or package.


Download ppt "Lecture 9: Programming Beans Topics: Bean Android SDK Date: Mar 29, 2016."

Similar presentations


Ads by Google