Method And Tech Examples

GUI example/base sketch

This little sketch has been set up to have the best practices for configuring p5js for apps and small installations. It includes:

  • full screen mode (press f).

  • ml5 is included

  • custom fonts from google

  • a simple GUI implementation is

  • fixed resolution for viewing on mobile platforms

  • a simple statemachine for making multiple views

QR Code reader

This example opens the webcamera and returns a qr code

Inline video player

If you need to convert video formats, then this tool is good MP4 is recommended as the encoding format.

(found this rough youtube embed example)

Openstreet map

It is possible to integrate map data from e.g. open street maps.

Based on /

(another example here)

combi version:

(note leaflet is also possible to use:

GPS location

Through the browser api you can get the location of your phone or laptop. This can be combined with map API etc.

Simple "read only" JSON Database

OBS! You can edit the database while the program is running, but it will not be saved. If you need to save data look here.

Read more here

You can use this viewer to show your data:

Read more about JSON here

with img =>

Make it editable online with a servive like this:


SVG manipulation

ARduino code

// This example uses an ESP32 Development Board

// to connect to


// You can check on your device after a successful

// connection here:


// by Joël Gähwiler


#define ONBOARD_LED 2

#include <WiFi.h>

#include <MQTT.h>

#include <ESP32Servo.h>

Servo myservo; // create servo object to control a servo

// 16 servo objects can be created on the ESP32

int pos = 0; // variable to store the servo position

// Recommended PWM GPIO pins on the ESP32 include 2,4,12-19,21-23,25-27,32-33

// Possible PWM GPIO pins on the ESP32-S2: 0(used by on-board button),1-17,18(used by on-board LED),19-21,26,33-42

int servoPin = 21;

WiFiClient net;

MQTTClient client;

unsigned long lastMillis = 0;

void connect() {

Serial.print("checking wifi...");

while (WiFi.status() != WL_CONNECTED) {





while (!client.connect("arduino", "public", "public")) {






// client.unsubscribe("/hello");


void messageReceived(String &topic, String &payload) {

Serial.println("incoming: " + topic + " - " + payload);

if (topic.equals("/carsharep5js") && payload.equals("on"))


digitalWrite(ONBOARD_LED, HIGH);



else if (topic.equals("/carsharep5js") && payload.equals("off"))



digitalWrite(ONBOARD_LED, LOW);


// Note: Do not use the client in the callback to publish, subscribe or

// unsubscribe as it may cause deadlocks when other things arrive while

// sending and receiving acknowledgments. Instead, change a global variable,

// or push to a queue and handle it in the loop after calling `client.loop()`.


void setup() {


WiFi.begin("oliver", "hesthest"); // OBSMADS

// Note: Local domain names (e.g. "Computer.local" on OSX) are not supported

// by Arduino. You need to set the IP address directly.

client.begin("", net);




// Allow allocation of all timers





myservo.setPeriodHertz(50); // standard 50 hz servo

myservo.attach(servoPin, 1000, 2000); // attaches the servo on pin 18 to the servo object

// using default min/max of 1000us and 2000us

// different servos may require different min/max settings

// for an accurate 0 to 180 sweep


void loop() {


delay(10); // <- fixes some issues with WiFi stability

if (!client.connected()) {



// publish a message roughly every second.

if (millis() - lastMillis > 1000) {

lastMillis = millis();

client.publish("/carshareesp32", "I am online");



Genkend objekter


Geolocation library