Skip to content

Commit a9cf23a

Browse files
author
Melle Dijkstra
committed
Refinement of logic and polishing up
1 parent 0d44f35 commit a9cf23a

26 files changed

+118
-304
lines changed

_includes/sidebar.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ <h1 class="text-center"><a class="no-link" href="/">Dijkstra<span class="brand-d
1919

2020
<!-- SOCIAL MEDIA -->
2121
<div class="margin-tb-20 text-lg text-center social-buttons">
22-
<a class="github" target="_blank" href="https://github.com/MelleDijkstra"><span
22+
<a class="github" target="_blank" href="https://github.com/melledijkstra"><span
2323
class="mdi mdi-github-circle"></span><span class="hidden">My github account</span></a>
2424
<a class="twitter" target="_blank" href="https://twitter.com/dijkstrascience"><span
2525
class="mdi mdi-twitter"></span><span class="hidden">My twitter account</span></a>

_includes/story_view.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<a href="{{ include.story.url }}">
44
<div class="trim">
55
<img class="image center-block img-responsive"
6-
src="/uploads/guides/{{ include.story.date | date: '%F' }}.jpg"
6+
src="/uploads/stories/{{ include.story.image }}"
77
alt="story image"/>
88
</div>
99
</a>

_posts/2018-03-21-trigonometry-in-p5.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@ layout: post
33
title: "Trigonometry in p5"
44
date: 2018-03-21 01:10:19 +0200
55
categories: p5 mathematics
6+
image: 2018-03-21.jpg
67
language:
78
color: f0db4f
89
name: Javascript
910
---
11+
Trigonometry sketch created with P5 a graphics library in JavaScript. The sketch uses trigonometry functions to translate polar coordinates to Cartesian coordinates.
12+
<!--more-->
13+
1014
[P5.js](https://p5js.org/) is a graphics library for JavaScript, it is based on [Processing](https://processing.org). In the process of learning p5, I wanted to create something challenging.
1115

1216
Another topic I was reading about was **[Polar coordinates](https://en.wikipedia.org/wiki/Polar_coordinate_system)** and the translation to **Cartesian coordinates**. So, I decided to do something with trigonometry. The Wikipedia page might look intimidating. However, translating the coordinates between the two is just some basic math. Just check out the code below!
13-
<!--more-->
1417

1518
### Here is the result:
1619

_posts/2018-04-02-android-bluetooth-connection-with-arduino.md

+32-16
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,35 @@ layout: post
33
title: "Android bluetooth connection with arduino"
44
date: 2018-04-02, 13:58:54 +0200
55
categories: android java bluetooth
6+
image: 2018-04-02.jpg
7+
language:
8+
color: 8bc34a
9+
name: Android
610
---
11+
This guide describes how to communicate from Android to Arduino using bluetooth communication. It describes the process of creating an application which notifies the user if the noise level is above a certain limit. Data is gathered from a sensor on the Arduino (KY-038). Bluetooth communication with (HC-04)
12+
<!--more-->
13+
714
All of the code used in this guide can be found on the following GitHub links:
815

9-
| Platform | Repository |
10-
| -------- | ------------------------------------------------------------ |
11-
| Android | [github.com/MelleDijkstra/SmartVolume](https://github.com/MelleDijkstra/SmartVolume) |
12-
| Arduino | [github.com/MelleDijkstra/ArduinoProjects/bluetooth-soundsensor](https://github.com/MelleDijkstra/ArduinoProjects/tree/master/bluetooth-soundsensor) |
16+
<table class="table table-condensed">
17+
<tr>
18+
<th>Platform</th>
19+
<th>Repository</th>
20+
</tr>
21+
<tr>
22+
<td><i class="mdi mdi-android"></i> Android</td>
23+
<td><a target="_blank" href="https://github.com/MelleDijkstra/SmartVolume">github/MelleDijkstra/SmartVolume</a></td>
24+
</tr>
25+
<tr>
26+
<td><i class="mdi mdi-console-line"></i> Arduino</td>
27+
<td><a target="_blank" href="https://github.com/MelleDijkstra/ArduinoProjects/tree/master/bluetooth-soundsensor">github/MelleDijkstra/ArduinoProjects/bluetooth-soundsensor</a></td>
28+
</tr>
29+
</table>
1330

1431
There are numerous ways to have a wireless connection between devices. One of them is bluetooth, which is actually quite easy to implement in Android. In this guide, I'll show you how to connect to a *paired* bluetooth device with the Android API.
1532

1633
Android has a specific API for Bluetooth connection. For in-depth information refer to their API guide [https://developer.android.com/guide/topics/connectivity/bluetooth.html](https://developer.android.com/guide/topics/connectivity/bluetooth.html)
17-
<!--more-->
34+
1835
## Prerequisites
1936

2037
- Android device
@@ -39,7 +56,7 @@ Instead of explaining how to use bluetooth in Android, I will be explaining how
3956

4057
We need permissions to use bluetooth & vibrate in the application:
4158

42-
```xml
59+
{% highlight xml %}
4360
<manifest ... >
4461
<uses-permission android:name="android.permission.BLUETOOTH" />
4562
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
@@ -48,7 +65,7 @@ We need permissions to use bluetooth & vibrate in the application:
4865
<uses-permission android:name="android.permission.VIBRATE"/>
4966
...
5067
</manifest>
51-
```
68+
{% endhighlight %}
5269

5370
### Step 2 - Android Code
5471

@@ -60,7 +77,7 @@ The interface is simply a single activity with the following fields:
6077

6178
```java
6279
public class MainActivity extends AppCompatActivity {
63-
// A unique request code which identifies that a result was from a enable bluetooth request
80+
// A unique request code which identifies that a result was from a enable bluetooth request
6481
final int REQUEST_ENABLE_BT = 32456;
6582
// The bluetooth adapter class which can be used to communicate with the bluetooth module
6683
// on this device
@@ -73,15 +90,14 @@ public class MainActivity extends AppCompatActivity {
7390
private int threshold = 100;
7491
// The unique identifier for the threshold SharedPreference, so it is persistent even if the application is closed
7592
private static final String PREF_THRESHOLD = "nl.melledijkstra.smartvolume.THRESHOLD";
76-
7793
...
7894
```
7995

8096
In `onCreate` I retrieve the bluetooth adapter of this device:
8197

82-
```java
98+
{% highlight java %}
8399
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
84-
```
100+
{% endhighlight %}
85101

86102
In `onStart` I retrieve the current threshold value from persistent storage (shared preference).
87103

@@ -94,7 +110,7 @@ The user can update this preference when clicking on the `Settings` option in th
94110

95111
I left in the default `FloatingActionButton` which is implemented when you create a new Android application. When the button is clicked I check if bluetooth is enabled, if so select a bluetooth device to connect with, if not, enable bluetooth first.
96112

97-
```java
113+
{% highlight java %}
98114
@Override
99115
public void onClick(View view) {
100116
if (mBluetoothAdapter != null) {
@@ -110,7 +126,7 @@ public void onClick(View view) {
110126
Toast.makeText(MainActivity.this, "Your device doesn't support bluetooth, sorry!", Toast.LENGTH_SHORT).show();
111127
}
112128
}
113-
```
129+
{% endhighlight %}
114130

115131
When `selectBluetoothDevice()` is run I show a dialog with the option to select a paired bluetooth device. The chosen bluetooth device is then used to communicate.
116132

@@ -268,7 +284,7 @@ That's it for the Android part!
268284
269285
### Step 1 - Building the circuit
270286
271-
![image of circuit](/uploads/guide-images/1522669477-812b4.png)
287+
![image of circuit](/uploads/story-images/1522669477-812b4.png)
272288
273289
The sound sensor that I use is the KY-038 (Also called "big sound").
274290
@@ -292,7 +308,7 @@ The bluetooth module is the HC-04. Connecting it is a little harder than the sou
292308

293309
Because the bluetooth module uses 3.3v for the data connection pins (RX & TX), it can't handle 5v from the Arduino. So the Arduino TX (transmit) pin which outputs 5v should be divided. This can be done with a 1K ohm resistor and a 2K ohm resistor. For specifics on wiring the HC-04 see [howtomechatronics](http://howtomechatronics.com/tutorials/arduino/arduino-and-hc-05-bluetooth-module-tutorial/).
294310
295-
![second image of circuit](/uploads/guide-images/circuit.jpg)
311+
![second image of circuit](/uploads/story-images/circuit.jpg)
296312
297313
### Step 2 - Arduino Code
298314
@@ -333,6 +349,6 @@ void loop()
333349
</div>
334350
</div>
335351
<div class="col col-xs-12 col-md-4">
336-
<img src="/uploads/guide-images/demo.gif" alt="Android Demo" />
352+
<img src="/uploads/story-images/demo.gif" alt="Android Demo" />
337353
</div>
338354
</div>

_posts/2018-04-27-twitter-visualization-with-processing.md

+9-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,18 @@ layout: post
33
title: "Twitter visualization with Processing"
44
date: 2018-04-27 22:53:32 +0200
55
categories: twitter processing
6+
image: 2018-04-27.jpg
7+
language:
8+
color: e76f00
9+
name: Java
610
---
11+
Twitter visualization of the latest trends created with the Java programming language. Created with Processing and the twitter4j library.
12+
<!--more-->
13+
714
With the Twitter4j library, you can retrieve Twitter data in the Java programming language fairly simple. In addition, the processing framework lets you create artful visualizations very easy, also with the Java language.
815

916
I wanted to combine the two, create a Twitter visualization. I choose to retrieve the newest trends from the whole world and let them slide on the window. The Twitter4j library can be found [here](http://twitter4j.org/en/index.html). And Processing [here](https://processing.org).
10-
<!--more-->
17+
1118
The actual code and repository can be found here:
1219

1320
https://github.com/MelleDijkstra/TwitterWave
@@ -100,7 +107,7 @@ class FloatingTrend {
100107

101108
### Impression
102109

103-
![Twitter Wave](/uploads/guide-images/twitterwave.png)
110+
![Twitter Wave](/uploads/story-images/twitterwave.png)
104111

105112
**Improvements**
106113

assets/compiled-assets/all-0e3f706f0de6684f17536f5b3d9edefb.css

-1
This file was deleted.

assets/compiled-assets/all-1aec0aa225c6ea1a814e6c5827d1500a.css

-1
This file was deleted.

assets/compiled-assets/all-6cc0e11151444de7e472392cf7a088db.css

-1
This file was deleted.

assets/compiled-assets/all-a4c57435a36f9be5a2756f8e59b2afc1.css

-1
This file was deleted.

0 commit comments

Comments
 (0)