Add examples

This commit is contained in:
Fabian Affolter 2017-11-09 09:45:16 +01:00
parent 9faf94b30e
commit 6f553ed23c
No known key found for this signature in database
GPG Key ID: DDF3D6F44AAB1336

View File

@ -57,4 +57,35 @@ sensor:
``` ```
{% endraw %} {% endraw %}
## {% linkable_title Examples %}
### {% linkable_title Arduino %}
For controllers of the Arduino family a possible sketch to read the temperature and the humidity could look like the sample below.
```
#include <ArduinoJson.h>
void setup() {
Serial.begin(115200);
}
void loop() {
StaticJsonBuffer<100> jsonBuffer;
JsonObject& json = prepareResponse(jsonBuffer);
json.printTo(Serial);
Serial.println();
delay(2000);
}
JsonObject& prepareResponse(JsonBuffer& jsonBuffer) {
JsonObject& root = jsonBuffer.createObject();
root["temperature"] = analogRead(A0);
root["humidity"] = analogRead(A1);
return root;
}
```
### {% linkable_title Digispark USB Development Board %}
This [blog post](/blog/2017/10/23/simple-analog-sensor/) describes the setup with a Digispark USB Development Board.