Arduino things!

This book is a short introduction to working with Arduino microcontrollers and various sensors. The subject on this is very broad, but this book is hopefully a short introduction to get you exited to work with electronics.

Arduino Introduction


What is Arduino?

Arduino is an open-source electronics platform based on easy-to-use hardware and software. Arduino boards are able to read inputs - light on a sensor, a finger on a button, or a Twitter message - and turn it into an output - activating a motor, turning on an LED, publishing something online. You can tell your board what to do by sending a set of instructions to the microcontroller on the board. To do so you use the Arduino programming language (based on Wiring), and the Arduino Software (IDE), based on Processing.

Read more about Arduino here: https://docs.arduino.cc/learn/starting-guide/whats-arduino

Hardware & Software

With Arduino there's 2 mayor sides at work

Hardware

Hardware to work with Arduino generally consists of an Arduino microcontroller (available in different forms such as Arduino Uno, Nano (smaller size), Leonardo (bigger memory) etc. Also hardware components are things we use to measure or translate data into the physical world such as sensors and actuators and other electronic components. 

We're working on a separate book for Electronic Components and Sensors and more in dept info as well

uploads2ftmp2f55b220bf-26a3-4104-90ed-06694e6b8d432fultrasonic6_W4Yu6O4wLN.png

Software

Arduino IDE programming environment. With the software we program certain behaviours of what we want the Arduino to do. This can be reading out sensor data, but also it can be sending controls to motors and other physical moving elements such as solenoids or water/air pumps. 

image.png

Screenshot of a piece code made in Arduino IDE 1.

If you want to get more information and basic knowledge it is recommended to visit the Arduino DOCS environment online. The basic Arduino website contains a lot of information, also regarding sales and projects, but the DOCS pages are a bit more structured towards getting started and beginners:

https://docs.arduino.cc

On the top left of this page, you will find the HARDWARE and SOFTWARE boxes with more info such as how to connect you're board for the first time, software updates and programming references.

Arduino Uno

The Arduino UNO board is the best board to get started with electronics and coding. If this is your first experience tinkering with the platform, the UNO is the most robust board you can start playing with.

The UNO is also the most used and documented board of the whole Arduino family.

Screenshot 2023-04-18 at 14.58.47.png

Buy an Arduino Uno Board - Kiwi Electronics  

Arduino UNO Setup Guide, Get Started, Pinout and Datasheet -> https://docs.arduino.cc/hardware/uno-rev3

Learning Arduino in different ways:

Method 1: Focus on 1 project at the time

Sometimes, students come to the Blackbox/Lab Pastoe with a clear project in mind and what components to get for it. This way is nice for beginners, because you have a clear goal in mind of what you want to make, and what components and/or sensors you need. 

It is very easy for some to get overwhelmed sometimes with the amount of tutorials, projects and sensors that are available. Having one project at the time makes it easier to understand the basic building blocks of both the hardware and software.

Things to keep in mind with Arduino projects:

Method 2: Freeform Experiments with Random Sensors 

Another approach is to buy a Grove Sensorboard online or rent one at the Blackbox/Uitleen IBB and Pastoe, and do some freeform experiments. The Grove Sensor kit contains another board with is ideal for those who have just started using Arduino to explore the vast space of electronics and programming.

Screenshot 2023-04-18 at 15.26.12.png

Grove is an open-source, modulated, and ready-to-use toolset and takes a building block approach to assemble electronics. This Kit includes a Base Shield to which the various Grove modules can be connected both individually, or together in various combinations and the plus side of Grove connectors is that you do not need soldering.

image.png

All of the modules use a Grove connector, which connects each of the components to a Base Shield in just a few seconds. The Base Shield can then be mounted on to an Arduino UNO board and can be programmed using the Arduino IDE.

Instructions

The Grove Sensor Kit comes with a lot of handy Instructions and very approachable tutorials for any level:

https://sensorkit.arduino.cc 

Screenshot 2023-04-18 at 15.51.34.png

Extra information:

Read more about the kit, available on Kiwi-Electronics 


Method 3: Let us know! 


Powering Arduino

Tutorials:
https://www.youtube.com/watch?v=I7MrL5Q7zvY
https://forum.arduino.cc/t/simplest-battery-power-to-arduino-nano-solution/530242

Links
https://forum.arduino.cc/t/simplest-battery-power-to-arduino-nano-solution/530242/2

Tips
If you want to use a powerbank in some cases depending on how much power the arduino needs from the bank it might turn off after 1 - a few minutes even though the powerbank is fully charged. It depends on the kind of powerbank. Some have a safety built in. But most of the time it is not mentioned in the description. Try different types of powerbanks.
If you use sensors or motors connected to your arduino it might work because they draw enough power. Also depends on the sensor.

Im still experimenting with this myself once i find more info i add it to this book.
At the moment i have tried 2 powerbanks (5000 & 10000 mAh) for Arduino Nano with seperate power for my small Neopixel Jewel (7 leds). Using batterypack 4xAA atm.

This might be interesting for Arduino Uno:
https://pmdway.com/collections/arduino-power-shield/products/rcr123a-16340-rechargeable-battery-power-shield-for-arduino

Arduino - Grove Sensor Kit

Another approach is to buy a Grove Sensorboard online or rent one at the Blackbox/Uitleen IBB and Pastoe, and do some freeform experiments. The Grove Sensor kit contains another board with is ideal for those who have just started using Arduino to explore the vast space of electronics and programming.

Screenshot 2023-04-18 at 15.26.12.png

Grove is an open-source, modulated, and ready-to-use toolset and takes a building block approach to assemble electronics. This Kit includes a Base Shield to which the various Grove modules can be connected both individually, or together in various combinations and the plus side of Grove connectors is that you do not need soldering.

image.png

All of the modules use a Grove connector, which connects each of the components to a Base Shield in just a few seconds. The Base Shield can then be mounted on to an Arduino UNO board and can be programmed using the Arduino IDE.

Instructions

The Grove Sensor Kit comes with a lot of handy Instructions and very approachable tutorials for any level:

https://sensorkit.arduino.cc 

Screenshot 2023-04-18 at 15.51.34.png

Extra information:

Read more about the kit, available on Kiwi-Electronics 

Motion Tracking with Sensors for Microcontrollers

Research by Blackbox into various sensors that can used with microcontrollers to track persons, objects, colours or other motions. What kind of differents sensors are there to use and what are the pro’s and con’s of each sensor?

Sensors of Interest:

Sensing Distance and Proximity:

More advanced sensing:

Can also be used:

Ultrasonic Sensor 

grove-ultrasonic-distance-sensor-preview_1-1-1030x773.png

Example project

The Ultrasonic Sensor is arguably the most common distance measuring sensor, also known as the Sonar sensor. It detects the distance to objects by emitting high-frequency sound waves. The object needs to be in line with the sensors not so wide range. Used a lot in DIY distance measurement projects, robotics, smart cars, drones. Most common used sensor is the HC-SR04.

+

- 

Detection is good for example; knowing if someone ‘entered’ the space and switch on video. Not so good for when you want one or multiple persons tracked. 

Screenshot 2023-04-25 at 15.54.47.png


Infrared Sensor (IR)  
Screenshot 2023-04-25 at 15.54.51.png

Example project

IR distance sensors work through the principle of triangulation; measuring distance based on the angle of the reflected beam. Used a lot in TV’s, computers and laptops, distance measurement projects, security systems, monitoring and control applications.

+

-

Screenshot 2023-04-25 at 15.55.03.png

PIR Motion Sensor

Screenshot 2023-04-25 at 15.54.55.png

Example project 

Passive infrared (PIR) sensors are sensitive to infrared (IR) rays and are mostly used for motion detection where humans move in or out of the sensor range.

Used a lot in appliances and gadgets for home or business (room detection). Also in DIY projects.

All living objects, whose body temperature is more than 0°C, emit the heat in form of infrared radiation through their body, also called as thermal radiations. This Radiated energy is invisible to human eye. These Signals can be detected by using PIR sensor which is specially designed for such purpose.

Grid Eye Illusion
Grid eye illusion


PIR sensor i.e. Passive Infrared Sensor, passive word indicates PIR Sensor does not generate or radiate any energy for detection purposes. PIR Sensors don't detect or measure "HEAT"; they detect the infrared radiation emitted or reflected from objects.They are small, inexpensive, low power and easy to use. They are commonly found at home, medical, factories etc. areas.

Microwave Doppler Radar Sensor

Screenshot 2023-04-25 at 16.00.00.png

For most of our Arduino projects that require knowing if someone has left or entered the area, the PIR sensor is an excellent choice. However, because they only detect movement from living things, they will generate fewer false alarms.

This is where a microwave sensor like the RCWL-0516 comes in handy. The RCWL-0516 microwave sensor detects any movement from any object and does not rely on heat signatures, making it more reliable in hot environments where a PIR sensor may not be as effective.

More about Doppler Microwave sensors here

Screenshot 2023-04-25 at 16.01.44.pngAnd a tutorial explaining the RCWL-0516 Microwave Doppler Radar sensor and running a beginner test can be found here by CircuitDigest .

Grove IR Disctance interrupter

is used to detect any object blocking the path of light. The module consists of an IR LED and a photosensor (phototransistor) pair. The light emitted by the IR LED gets reflected by any object placed in front of the sensor and this reflection is detected by the photosensor(phototransistor). Any white (or lighter) colored surface reflects more than black (or darker) colored surface.

IR-dist-intr.png

When the reflected light is detected, it produces Digital HIGH (or Binary 1) output on the SIG pin. The on-board LED indicator will also glow. If no reflection is detected or if the object is too far from the sensor, the output on the SIG pin stays at Digital LOW (Binary 0). The on-board LED indicator will be off as well. The detectable range of this sensor is 7.5–40 cm. The module incorporates a Rail-to-Rail Operational Amplifier to amplify the output of phototransistor. There is a potentiometer which can be used to adjust the gain of the amplifier, that is, sensitivity of detection.
More info & sample project here



Lidar TF Luna

TF-Luna_LiDAR_Range_Sensor.png

TF-Luna is a single-point ranging Lidar based on the TOF principle. With its unique optical and electrical design, it adopts an 850nm infrared light source to achieve stable, accurate, and highly sensitive distance measurements. 
More information here

Lidar TF Luna Sensor example project

Controlling LEDstrips with Arduino

LED Strips and Arduino

With the Adafruit Neopixel library, it is very easy to work with controlling different types of LED's using Arduino. Adafruit has a very extensive "Adafruit NeoPixel Überguide" available online, where you can follow a step-by-step guide for controlling LED strips, panels and individual led's. 

NeoPixel options:


Screenshot 2023-04-26 at 11.01.54.png
Screenshot 2023-04-26 at 11.17.25.png
Strips Rings

Screenshot 2023-04-26 at 11.17.31.png

 

 

 

 

 

 

 

 

Screenshot 2023-04-26 at 11.17.45.png


Matrices

Pins

image.png

ETC...

^^ link to more options available via kiwi electronics

Neon-Like Stips

Images from Adafruit

Basic NeoPixel LED strip setup

HARDWARE

Materials needed:

For controlling LED strips and Arduino you can build the following hardware:

Screenshot 2023-04-26 at 11.25.09.png

Usefull video until 3:50

SOFTWARE

Launch the Arduino IDE.

If you have not installed the NeoPixel Library for Arduino, first make sure to do that first.

Video

https://learn.adafruit.com/adafruit-neopixel-uberguide/arduino-library-installation 

If you want to understand more about Arduino and Libraries? Read more here...

From the File menu, select

Examples→Adafruit NeoPixel→strandtest


Powering NeoPixels in different ways

Other methods for powering ledstrips beside the simple standard power supply are:

You must use a 3-5V DC power supply to power these strips, do not use higher than 6V or you can destroy the entire strip– yikes!
Example 1 AA or AAA = 1,5 V

LED Power calculator here!

When choosing any option for powering the ledstrips, always take into account that you have enough amperage provided for the strips. Checkout the Adafruit page for more details regarding power options.

Powering Arduino in different ways


If you want to use a powerbank in some cases depending on how much power the arduino needs from the bank it might turn off after 1 - a few minutes even though the powerbank is fully charged. It depends on the kind of powerbank. Some have a safety built in. But most of the time it is not mentioned in the description. 
Try different types of powerbanks or use info from these links:
https://www.youtube.com/watch?v=I7MrL5Q7zvY
https://forum.arduino.cc/t/simplest-battery-power-to-arduino-nano-solution/530242

Im still experimenting with this myself once i find more info i add it to this book.
At the moment i have tried 2 powerbanks (5000 & 10000 mAh) for Arduino Nano with seperate power for my small Neopixel Jewel (7 leds). Both dont work. Using batterypack 4xAA atm.


Arduino Simple Serial communication with multiple values

Sending values from an Arduino to a computer can sometimes be a bit daunting... Sending only one value is pretty straightforward, but when it comes to sending multiple values, there are many scenario's on how to send out the values in a manner that enables you to distinguish them properly on the computer side. 

This page offers an explanation and the example code (see the attachments to this post on the left side of the page) to prepare for this task in a simple, straightforward way.

Arduino communicates to other devices over USB (User Serial Bus) this means that, by default, everything that is sent out is Serialised: the communication contains only one message at a time, bigger messages or chunks of data will be split into pieces that are sent one at a time, after each other.

(as opposed to Parallel communication, where multiple messages are sent and transfer, parallel to each other, at the same time)

Before we can get to sending out any values, we first have to initialise Serial communication from the Arduino by putting the following command in void setup()

void setup() {
  Serial.begin(9600); //start Serial communication with a speed of 9600 baud
}

Serial communication has a significant draw on both the computing power of the Arduino microcontroller ánd power consumption, that's why the Serial port on the board is off by default. 

Now we're ready to start sending data!

So, when you want to send out values from, lets say, all Analog outputs, you can send out all the values one by one, using a for loop in void loop() like this:  

void loop() {
  for (int i = 0; i < 6; i++) {  //iterate through all the analog inputs 
    int value = analogRead(i); //put the read value into and int variable
    Serial.print(value);  //and send the value out over Serial
  }

The data that's been sent out to the computer is stored in a Serial memory buffer, until a program comes along and reads the data in that buffer. Once read, the data will be erased, so there's only one application at a time that can connect to, and read from the buffer. The simplest way to read the Arduino Serial buffer on a computer, is using the Serial Monitor in the Arduino IDE, found under the button in the right top corner of the program:

Serial Monitor.png

Let's test this on Arduino and have a look at the Serial Monitor to see what kind of data is coming in..

Screenshot 2023-08-31 at 15.16.03.png

When sending the data out this way, all the incoming values are concatenated together in one big chunk of numbers... There's no way of distinguishing the separate analog values anymore.

The serial monitor is reading values in one row until it encounters a 'newline' character ('\n') since we never send a 'newline', all the numbers are read in one long oblivious stream.

We could easily fix this by changing the Serial.print(value); line to Serial.println(value);, The Serial.println() command, forces the Arduino to send a 'newline' after each value, resulting in the values coming in into the console like this:

Serial output println.png

Now, at least all the different input values are shown separately, but now there's no way of distinguishing which number belongs to which input...!

Most computer software that can receive Serial data (Processing, Isadora, TouchDesigner, etc.) utilise routines to separate values from a Serial string using 'separating' characters. For example Processing has a function that is called split() Processing Reference for split()

This function reads the incoming string and stores all characters it receives in between the separating characters in an array in memory.

The Processing routine to do this would look like this:

// the 'void serialEvent' function is triggered each time a '\n' is discovered 
// in the Serial buffer. The function executes and passes the values 
// stored in the memory of 'arduinoIn'
void serialEvent (Serial arduinoIn) {
  // convert the incoming Serial value to a String and put in memory
  String inString = arduinoIn.readStringUntil('\n');
  // only continue if there's actually anything stored in the String
  if (inString != null) {
    //print the raw incoming string to the console
    println(inString);
    // trim off any whitespace:
    inString = trim(inString);
    // split the incoming string and put the values in the inputVals array
    inputVals = int(split(inString, '-')); //you can choose a separating character that's logical to you
  }
}

So: in order for Processing to be able to separate the values and put them in the inputVals[] array, we need to format the messages we're sending out from Arduino like this:

valueA0-valueA1-valueA2-valueA3-valueA4-valueA5'\n'

This can be done by organising our Arduino send loop like this:

void loop() {
  //iterate through all the analog inputs 
  //and send out over Serial
  for (int i = 0; i < 6; i++) {
    int value = ;
    Serial.print(value);
    if (i < 5) {
      //send denominating '-' characters
      //(except after the last value)
      //technically not needed, but it makes the string look nicer in the console :)
      Serial.print('-');
    }
  }
  //end the string of values with a newline
  Serial.println();
}

When inspecting the incoming data in the Serial Monitor, it looks like this:

Screenshot 2023-08-31 at 16.30.54.png

Arduino is now sending out the values of all 6 Analog inputs, separated with '-' characters, as one 'sentence' at a time. Ready for Processing (or other applications) to be split up and used as separate values. 

Please check the attached files (on the left side of the page) for different examples of using this wat of Serial communication.

Arduino script to Control LED strip via wifi

Dit is een scriptje om een ESP8266 arduino module te verbinden met wifi (via een wifimanager / hotspot) en zichzelf aan te bieden als ArtNetNode (wanneer de software dit ondersteunt). fijn script, werkt goed, wel even concentreren op de nodige libraries om te compilen.
in essentie kan je de data pin en het aantal leds invoeren en gaan met die banaan
Werkt met NodeMCU
het is bedoeld voor WS2812 LEDs / neopixels. maar kan zeer eenvoudig omgezet in andere soorten adresseerbare LEDS, mits RGB (niet RGBW)

------------------------------
download hier:
https://nextcloud.hku.nl/s/BH3SeoLtS4m7dy2


Deze informatie komt van Tony Schuite (docent IPD locatie theater)

UltraSonic of PIR sensor Arduino & Touchdesigner or Isadora

Deze manual werkt voor PIR (passive infrared) bewegings sensor en ook voor de Ultrasonic sensor

Beschrijving PIR sensor (Duits)
https://www.reichelt.nl/nl/nl/raspberry-pi-infrarood-bewegingsmelder-hc-sr501-rpi-hc-sr501-p224216.html?PROVID=2809&gclid=CjwKCAjwzJmlBhBBEiwAEJyLu7b6GP911-3vaEA33hXK1vssSrwNGtU83omn4zjNUqw3wLPmZsHYzRoCQnEQAvD_BwE
Detectieafstand: 3-7m

PIR-schema(1).jpg

Code voor PIR sensor:

/*
Arduino with PIR motion sensor
For complete project details, visit: http://RandomNerdTutorials.com/pirsensor
Modified by Rui Santos based on PIR sensor by Limor Fried
*/
int led = 13; // the pin that the LED is atteched to
int sensor = 2; // the pin that the sensor is atteched to
int state = LOW; // by default, no motion detected
int val = 0; // variable to store the sensor status (value)

void setup() {
pinMode(led, OUTPUT); // initalize LED as an output
pinMode(sensor, INPUT); // initialize sensor as an input
Serial.begin(9600); // initialize serial
}

void loop(){
val = digitalRead(sensor); // read sensor value
if (val == HIGH) { // check if the sensor is HIGH
digitalWrite(led, HIGH); // turn LED ON
delay(100); // delay 100 milliseconds
if (state == LOW) {
Serial.println("1");
state = HIGH; // update variable state to HIGH
}
}
else {
digitalWrite(led, LOW); // turn LED OFF
delay(200); // delay 200 milliseconds
if (state == HIGH){
Serial.println("0");
state = LOW; // update variable state to LOW
}
}
}


Test of het werkt:

maak in Arduino verbinding met de Arduino door de juiste board en poort te kiezen, Board: Arduino Uno & poort Mac: /dev/cu.usbmodem1301 Serial Port (USB), Poort PC: COM3

installeer de code op de Arduino door links bovenin op het pijltje te drukken.
test de code en setup door rechts boveninn op het vergrootglaasje te drukken.
werkt het niet neem contact op met Blackbox medewerker voor een check van je setup.

Data ontvangen in Isadora:
Zet serial monitor in Arduino uit
gebruik de actor: serial in watcher text

verander de instelling van de serial in watcher actor:
open de actor by double klikking it and fill in this code : value:int=eol
in actor put eom char on 10

Screenshot 2025-01-14 at 10.48.07.png


Zet verbinding met Arduino aan:
1 menu > communications > serial port setup 
2 Port 1 > Device > Select > kies USB poort
Als Isadora de poort niet laat zien of zegt dat hij Busy is kies dan None en daarna weer de USB poort. > OK
Menu > communications > Enable serial ports

Screenshot 2025-01-14 at 10.52.26.png Screenshot 2025-01-14 at 10.51.58.png

Aan de rechterkant van de serial in watcher actor zou de waarde in msg rcv moeten veranderen van - naar X 
En value moet veranderen van 0 naar 1

Voorbeeld Isadora met een video:

Screenshot 2026-02-26 at 12.33.32.png

--------------------------------

Beschrijving ultrasonic sensor:
https://randomnerdtutorials.com/complete-guide-for-ultrasonic-sensor-hc-sr04/
Detectieafstand: 2cm tot 400cm
Werkt goed op solid surface, stoffen zoals kleding is minder accuraat.

Installatie Ultrasonic sensor check volgende tutorial >>>

Data > touchdesigner:
https://www.youtube.com/watch?v=lkudxFrwPXU

Let op als je in Touchdesigner of Isadora de input wilt testen dan moet je in Arduino je Serial Monitor uitzetten.
Anders kan de software niet communiceren met de Arduino .


Deze tutorial is getest door Simone van Dordrecht (Blackbox medewerker IBB)

Learning & understanding Arduino through helpful projects

There are tutorials on most anything out there!
below is a selection of websites to make coding & debugging microcontrollers like Arduino easier

Neopixel Effect Generator
Create your animation for the Neopixel LED Strip and press "Generate Arduino Code" to get it as code to copy to the Arduino IDE. 

wokwi: Arduino
Simulate IoT Projects in Your Browser

Tinkercad: Circuits
From blinking your first LED to reimagining the thermometer, we’ll show you the ropes, buttons, and breadboards of electronics.

Microsoft make code
Microsoft MakeCode is an open source platform for creating engaging computer science learning experiences that support a progression path into real-world programming.
including a simulator to debug your code & block coding 


Books

IMG20240521151113.jpg

Here you will find some suggestions for Arduino books

LiDAR with Arduino - TF-Luna Sensor

Als je iets anders wilt dan Ultrasonic Sensor HC-SR04 kwa afstand namelijk meer afstand met minder ruis kun je kiezen voor de TF-Luna Sensor. Dit is een Lidar sensor die met behulp van een laser de afstand tot een object meet tussen 0,2 en 8 meter.
> De TF Luna LiDAR-afstandsmeter biedt een bereik van 0,2 m-8 m, een resolutie van 1 cm en een nauwkeurigheid van ±6 cm @ (0,2 m-3 m) <

Materiaal:
Arduino Nano + USB kabel
TF-Luna Sensor
Breadboard
Jumper wires male/male
kabel verbinders voor snel testen zonder solderen

Ik heb om dit aan de praat te krijgen de volgende bron gebruikt:
https://www.diyengineers.com/2022/06/02/lidar-how-to-use-with-arduino/

Op deze site kun je belangrijke documenten downloaden zoals datasheet en user manual maar die heb ik amper nodig gehad.
https://en.benewake.com/TFLuna/index.html

Shop:
https://eu.robotshop.com/nl/products/benewake-tf-luna-8m-lidar-afstandssensor


Wat ik lastig vond bij deze is dat er geen JST GH1.25 - 4P naar Dupont verloopjes bij zaten dus heb ik de kabel gestript en waco verbindingsklemmen gebruikt om te testen. Solderen kan natuurlijk ook maar ook dat was me even teveel werk.
Kiwi Electronics verkoopt ze met de handige kabels maar niet op voorraad. https://www.kiwi-electronics.com/nl/tf-mini-s-lidar-module-10359?search=lidar

IMG_4943.JPGpins-arduino-nano.png

Ik heb een Arduino Nano gebruikt. In de tutorial wordt de Arduino Uno gebruikt en voor data overdracht de poorten ICSP2. Volgens bovenstaand schema kan je daarvoor IC2 pins Analog A4 & A5 gebruiken.

De 6e kabel hoef je niet te gebruiken.

Installeer Arduino software
https://www.arduino.cc/en/software

Arduino Library:
https://github.com/budryerson/TFLuna-I2C
Verbind de arduino met mini usb kabel aan je computer, kies links bovenin de Arduino software venster je type arduino board en de usb poort

Screenshot 2025-01-06 at 16.32.39.png

Volg de aanwijzingen in de tutorial via link bovenaan dit document om de library via Arduino software te installeren.
Ga bovenin je menu balk in de arduino software naar Tools > Serial Monitor.
Zet rechts onderin 9600 Baud om naar 115200 Baud, anders krijg je rare resultaten.

Houd je hand boven de lidar sensor en zie de waardes veranderen.

Als je nog info mist in deze uitleg of iets is niet duidelijk laat het me dan weten dan pas ik het aan.
Simone.vandordrecht@hku.nl

Voorbeeld project:  intensiteit licht LED pixel ring beïnvloeden door afstandmeting Lidar TF Luna sensor

Materiaal:
Neo pixel ring 12 of 16 pixels
Arduino Nano + USB kabel
TF-Luna Sensor
Breadboard
Jumper wires male/male
Resistor  330 Ω tot 470 Ω
Universal AC adapter 5V
Terminal block to 2.1mm DC barrel jack - Female

Bronnen voor testen:
https://www.diyengineers.com/2022/06/02/lidar-how-to-use-with-arduino/
https://learn.adafruit.com/adafruit-neopixel-uberguide/arduino-library-installation
https://medium.com/@elonskolnik/arduino-uno-tutorial-neopixel-ring-setup-9fafc099c89a
https://chatgpt.com/share/6787fc7b-e388-8006-98cc-3678b193ec44


Combineren:

Soldeer de kabeltjes van de TF Luna aan jumper wires en gebruik krimpkousjes voor bescherming
Power de Pixelring apart van de Arduino, zorg dat de ground wel doorlust naar de ground van arduino en TF Luna.

Screenshot 2025-01-15 at 17.50.41.png
(Duidelijk schema hiervan moet ik nog maken)

Alternatief voor draadloos project: Gebruik een powerbank 5V voor stroom voor de arduino en een batterij pack bijvoorbeeld 4x AA voor de stroom voor pixelring. Foto hiervan volgt..
Meer info kun je hier vinden: 
https://bookstack.hku.nl/books/arduino-things/page/controlling-ledstrips-with-arduino

Code:

#include <Adafruit_NeoPixel.h> //https://github.com/adafruit/Adafruit_NeoPixel
#include <TFLI2C.h> //https://github.com/budryerson/TFLuna-I2C
#include <Wire.h> // Instantiate the Wire library

#define PIXEL_PIN 6 // Pin verbonden met de NeoPixel-ring
#define NUM_PIXELS 21 // Aantal LEDs op de ring
#define MAX_BRIGHTNESS 255 // Maximale helderheid
#define MIN_BRIGHTNESS 5 // Minimale helderheid

Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_PIXELS, PIXEL_PIN, NEO_RGBW + NEO_KHZ800); //lees achterop de leds of in de specificaties online welk type het is en pas de informatie hier aan, oorspronkelijk stond GRB in de code maar de ledring is RGBW dus aangepast
TFLI2C tfLuna;

void setup() {
Wire.begin();
Wire.setClock(100000); // Stel I2C-snelheid in op 100 kHz


strip.begin();
strip.show(); // Zorgt ervoor dat alle pixels uit staan
Serial.begin(9600);

Serial.println("Start setup");
delay(1000);

// Probeer verbinding met de TF-Luna
Serial.println("Verbinding met TF-Luna...");

uint16_t frameRate;
if (tfLuna.Get_Frame_Rate(frameRate, TFL_DEF_ADR)) {
Serial.print("Frame rate: ");
Serial.println(frameRate);
} else {
Serial.println("Kon frame rate niet ophalen. Controleer de verbinding.");
}
}

void loop() {
int16_t distance = 0;

// Haal de afstand op van de TF-Luna
if (tfLuna.getData(distance, TFL_DEF_ADR)) {
// Bepaal helderheid op basis van afstand
int brightness = map(distance, 10, 100, MAX_BRIGHTNESS, MIN_BRIGHTNESS); // 10 staat voor minimale afstand, 100 staat voor maximale in cm, past dit aan als je meer of minder afstand nodig hebt
brightness = constrain(brightness, MIN_BRIGHTNESS, MAX_BRIGHTNESS);

// Stel helderheid in en kleur de LEDs
strip.setBrightness(brightness);
for (int i = 0; i < NUM_PIXELS; i++) {
strip.setPixelColor(i, strip.Color(0, 255, 255, 0)); // Pas hier de kleur aan, volgorde = G, R, B, W (vreemd, klopt niet met de info van de ring maar het werkt)
}
strip.show();

// Print de afstand en helderheid naar de Serial Monitor
Serial.print("Afstand: ");
Serial.print(distance);
Serial.print(" cm, Helderheid: ");
Serial.println(brightness);
} else {
// Geef een foutmelding als de data niet kan worden opgehaald
Serial.println("Fout bij ophalen afstandsgegevens.");
tfLuna.printStatus(); // Laat de foutstatus zien
}

delay(100); // Kleine pauze voor de volgende meting
}

Touch (knock) sensor with Piezo

If you want to make a simple touch sensor but you don't have the fancy ones around you can also use a piezo element, which come with a lot of basic arduino starter sets.

What you need:

piezo element

B400%2FEKULIT-190051.jpg?type=Product&
breadboard
breadboard-afmetingen-81-x-55-x-8mm.jpg 

resistor 1 M ohm


images?q=tbn:ANd9GcTBA4twFjVplLxCILOemIsr5NFGbJQkJYWiRA&s

piece of paper tape

shopping?q=tbn:ANd9GcRQQMlNLQViZ2PP1b8sfp-hSPZUXq4crtlXjPWlL6NVMVDzglMaPLBn3jHA5zJfmCBD8wS55BpYr2IThg77X8QI9b-zlTjYz-PHjaxb4bZ6jDsrj37qDzrK1Ltsos9aeEQJR1HhIg&usqp=CAc
some male/male jumper wires

This video explains it all. To make the input visual, open the serial Monitor from the Tools menu.





 

Grove - Ear-clip Heart Rate Sensor

Screenshot 2025-02-19 at 14.22.59.png

Info & Arduino code


https://wiki.seeedstudio.com/Grove-Ear-clip_Heart_Rate_Sensor/

Parts

Grove - Ear-clip Heart Rate Sensor
https://www.kiwi-electronics.com/nl/grove-ear-clip-heart-rate-sensor-2058

Grove - Base Shield voor Arduino V2
https://www.kiwi-electronics.com/nl/grove-base-shield-voor-arduino-v2-2100

Arduino uno
https://www.kiwi-electronics.com/nl/arduino-uno-rev3-atmega328-729?search=arduino%20uno

usb kabel
https://www.kiwi-electronics.com/nl/usb-a-naar-usb-b-kabel-05-meter-763

Software to receive the data

If you get this device through blackbox employe the code is already installed on the Arduino board
Download the Isadora file, Communications > Enable serial ports 
Output > force stage preview & go

Isadora file: heart_beat_visualisatie_isadora_mk2.izz (credits for this file: Tjerk Stoop)

Arduino - Adafruit MPR121 12-Key Capacitive Touch Sensor Breakout

On this page you will find a tutorial for how to connect and use a Adafruit MPR121 12-Key Capacitive Touch Sensor Breakout to an Arduino board to send the data to for example Isadora. This is useful because the Adafruit board can act as an replacement for the  Bare Conductive since they are no longer active since 05-03-2025.

image.png

Step 1:

Buy an Adafruit MPR121 12-Key Capacitive Touch Sensor Breakout  for example here

Step 2:

Wire up the board:

image.png

  • Connect Vin to the power supply, 3-5V is fine. Use the same voltage that the microcontroller logic is based off of. For most Arduinos, that is 5V
  • Connect GND to common power/data ground
  • Connect the SCL pin to the I2C clock SCL pin on your Arduino. On an UNO & '328 based Arduino, this is also known as A5, on a Mega it is also known as digital 21 and on a Leonardo/Micro, digital 3
  • Connect the SDA pin to the I2C data SDA pin on your Arduino. On an UNO & '328 based Arduino, this is also known as A4, on a Mega it is also known as digital 20 and on a Leonardo/Micro, digital 2
Step 3:

Install the Arduino library and test. You could use the Adafruit library but in our experience the Bareconductive library works better it adds proximity options.

Adafruit

  • Open up the Arduino library manager and search for: Adafruit MPR121 library and install it. 
  • Then open Examples -> Adafruit MPR121 -> MPR121test

    Thats it! Now open up the serial terminal window at 9600 speed to begin the test.  Make sure you see the "MPR121 found!" text which lets you know that the sensor is wired correctly. Now touch the 12 pads with your fingertip to activate the touch-detection

    You now have the board successfully working! 

    if you get the message: "MPR121 not found, check wiring?" make sure to check all the wires on the side of the sensor and the side of Arduino to make sure you did not make any mistake.



Bareconductive

  • Download the Zip file from here, Click on the green "<> Code" button and then on "Download ZIP."
  • Manually install the library in your Arduino software, go here and find "Importing a .zip Library", follow these steps.
  • Use the sketch "Datastream.ino" that is edited by HKU-ect to be used together with Bare Conductive and adds the proximity option, this file can be found here.
  • Save it under a new name for instance Datastream-proximity.ino so its easy to find when you come back to this project.

Step 4:

Let's get the data over to Isadora!

For this we will use the Arduino "Datastream.ino" that is meant to be used together with Bare Conductive this file can be found here

Open the file in Arduino and go to line 44: 

if(!MPR121.begin(0x5C)){

and change to:

if(!MPR121.begin(0x5A)){

This weird thing: 0x5C is the IC2 address of the board. On the bare conductive this is 0x5C but if we connect it to the Arduino it is 0x5A.

Upload the code and then you can us it in Isadora with the same Isadora Patch as you use for the Bare Conductive!
Find it here: bareConductiveDemo.izz

If you want to change the sensitivity of the board change the values of this code:

// this is the touch threshold - setting it low makes it more like a proximity trigger
// default value is 40 for touch
const int touchThreshold = 8;
// this is the release threshold - must ALWAYS be smaller than the touch threshold
// default value is 20 for touch
const int releaseThreshold = 4;

Sources

Grove - IR Distance Interrupter v1.2

IR-dist-intr.png

Grove - IR Distance Interrupter is used to detect any object blocking the path of light.
The light emitted by the IR LED gets reflected by any object placed in front of the sensor and this reflection is detected by the photosensor(phototransistor). Any white (or lighter) colored surface reflects more than black (or darker) colored surface.

You can borrow this sensor for testing from Blackbox workshop employe at location IBB: blackbox.ibb-pastoe@hku.nl

When the reflected light is detected, it produces Digital HIGH (or Binary 1) output on the SIG pin. The on-board LED indicator will also glow. If no reflection is detected or if the object is too far from the sensor, the output on the SIG pin stays at Digital LOW (Binary 0). The on-board LED indicator will be off as well.

The detectable range of this sensor is 7.5–40 cm.  
There is a potentiometer which can be used to adjust the gain of the amplifier, that is, sensitivity of detection. Use the best fitting scredriver for this and be very sensitive!!!

Note

This product is mildly sensitive to non-IR radiations also and hence any bright light on photosensor impairs or disturbs IR light detection.

Material required

Connections

1.Connect Base shield to arduino board Grove, connect IR Distance Interrupter v1.2 to Arduino UNO with Grove cable. port D6

2.Place and hold the Reflective photosensor towards white(or light) colored surface. For adjusting sensitivity read this

3.Create an Arduino sketch and copy the below code into it.

void setup()  {
    Serial.begin(9600);
    pinMode(6,INPUT);
}
void loop()  {
    while(1)  {
        delay(500);
        if(digitalRead(6)==LOW)  {
            Serial.println("Somebody is here.");
        }
        else  {
            Serial.println("Nobody.");
        }
    }
}

5.Connect Arduino to your comuter & Upload the code.
If you do not know how to upload a Arduino sketch, please visit https://www.arduino.cc/en/Guide/Windows for Windows user or https://www.arduino.cc/en/Guide/MacOSX for Mac user.

6.When the path of light is blocked by some object, you would see "Somebody is here." in Serial Terminal else you will see "Nobody."

For connecting with Isadora read this

Source:

 https://wiki.seeedstudio.com/Grove-IR_Distance_Interrupter_v1.2/

Infrared (IR) break-beam sensor

Infrared (IR) break-beam sensors are an easy way to detect movement. This sensor has a transmitter and receiver part. Point the transmitter at the receiver to create a light beam that will trigger the receiver if this bundle is interrupted.

KW-1516-1-1400x1050w.jpg

For this test i didn't use an LED as mentioned in the code and tutorial (see sources bottem of the page)
You can leave it out of the setup if you don't need it and connect the data(yellow wire) directly to pin 5 (digital) on the arduino.
Because it works with infrared light, use it indoors and close the curtains and maybe don't use halogen lights ;) I made that mistake.

Material

Assembly

1. If you buy this sensor new you will likely receive this without jumper wires. To make testing easy solder on some jumper wires. 

2. Connect the sensors to the arduino, position them towards each other in a straight line. you can use a small box like in the tutorial in the source (below this text)
Sice you have only one 5V output on your arduino you can split up the power for both sensors by using a breadboard.
You can use this schematics:

schematic IR BreakB.jpg

with breadboard:

Screenshot 2026-03-05 at 14.29.56.png


3. Create an Arduino sketch and copy this code into it:


void setup() {
  
  Serial.begin(9600);
  pinMode(5, INPUT_PULLUP);
  pinMode(13, OUTPUT);

}

void loop() {

  int val = digitalRead(5);

  if (val == 0) //Beam is broken
  {
    digitalWrite(13, LOW);
  }
  else
  {
    digitalWrite(13, HIGH);
  }

  Serial.print(" ");
  Serial.println(val);

  delay(100);


}

4. Connect Arduino to your comuter & Upload the code.
If you do not know how to upload a Arduino sketch, please visit https://www.arduino.cc/en/Guide/Windows for Windows user or https://www.arduino.cc/en/Guide/MacOSX for Mac user.

5. Open the serial monitor by clicking the Magnifying glass in the top right corner of the window.
When the path of light is blocked by some object, you would see "0" in Serial Terminal else you will see "1"
This is changed in the code from source github page (below text) so you can use the output in for instance Isadora.
If you leave the text like in the original code
  Serial.print("The value of pin 5 is: ");
the actor output in Isadora will not give 1 or 0. Only - or X

For connecting with Isadora read this

You can borrow this sensor for testing at the Blackbox location IBB. Contact: blackbox.ibb-pastoe@hku.nl

source: 

Sensor: https://www.kiwi-electronics.com/nl/infrarood-straal-detector-5mm-leds-1577?search=kw-1516

Video: https://www.youtube.com/watch?v=GWdDeB7Sltw

Code from video: https://github.com/nickredsox/youtube/blob/master/Arduino/IR%20Beam/ir_beam_arduino/ir_beam_arduino.ino

Time of Flight Distance Sensor VL53L4CD

The Adafruit VL53L4CD Time-of-Flight Distance Sensor is ideal for accurate distance measurements. The sensor delivers stable results from approximately 1.0 mm to 1300.0 mm with high repeatability. Thanks to its narrow measuring beam, it is ideal for robotics, obstacle detection, automatic measurements or interactive installations.

It has a STEMMA QT / Qwiic connector for easy plug-and-play connections without soldering.

  • Measuring range from approximately 1.0 mm to 1300.0 mm
  • Compatible with 3.3V and 5V
  • Narrow beam (FoV approx. 18 degrees) for precise detection
  • STEMMA QT / Qwiic connector for easy connection
  • Fast measurements up to about 100 Hz

1 Material:

2 Assembly

Screenshot 2026-03-09 at 13.58.23.png

Wire  using the STEMMA QT connector.
If you are using a 3V board, like an Adafruit Feather, wire the board's 3V pin to the VL53L4CD VIN.


3 Software & code

In the Arduino software Click the Manage Libraries ... menu item (under Tools), search for VL53L4CD, and select the STM32duino VL53L4CD library. Install it.

The library comes with some example sketches, I used one of them and adjusted the code so the useless information like status, signal, tekst is removed. It now only outputs a stream of values.

Open a new arduino file ande replace the code with this:

#include <Arduino.h>
#include <Wire.h>
#include <vl53l4cd_class.h>

#define DEV_I2C Wire

VL53L4CD sensor(&DEV_I2C, A1);

void setup() {
Serial.begin(115200);
Wire.begin();

sensor.begin();
sensor.VL53L4CD_Off();
sensor.InitSensor();

// Hoge nauwkeurigheid
sensor.VL53L4CD_SetRangeTiming(200, 0);

// Start met meten
sensor.VL53L4CD_StartRanging();
}

void loop() {
uint8_t dataReady = 0;
VL53L4CD_Result_t results;

// Wacht tot er nieuwe data is
do {
sensor.VL53L4CD_CheckForDataReady(&dataReady);
} while (!dataReady);

// reset interrupt
sensor.VL53L4CD_ClearInterrupt();

// meetresultaat ophalen
sensor.VL53L4CD_GetResult(&results);

// alleen afstand printen
Serial.println(results.distance_mm);

}

5 Connect the arduino to your computer. 

Connect Arduino to your computer & Upload the code.
If you do not know how to upload a Arduino sketch, please visit https://www.arduino.cc/en/Guide/Windows for Windows user or https://www.arduino.cc/en/Guide/MacOSX for Mac user.

Open the serial monitor by clicking the Magnifying glass in the top right corner of the window.
You might need to change the Baud rate to: 115200 before you get good results. Do this in the top right of the serial monitor field.
You should now see a stream of data measuring the distance to the object in front of the sensor. Hold your hand in front of the sensor and move it.

For connecting with Isadora read this

You can borrow this sensor for testing at the Blackbox location IBB. Contact: blackbox.ibb-pastoe@hku.nl


Source for this page: https://learn.adafruit.com/adafruit-vl53l4cd-time-of-flight-distance-sensor/arduino

IR Distance Sensor SHARP GP2Y0A02YK with Arduino

 

KW-1476-2-1400x1050h.jpg

The Sharp GP2Y0A02YK infrared ranger is able to continuously measure the distance to an object. The usable range is 20 cm to 150 cm. The device generates an analog voltage that is a function of range, and the output voltage can be measured by an analog-to-digital (ADC) input line. The voltage will range from approx. 0.4V at 150cm to 2.7V at 20cm. 

1 Material:


- sensor: Sharp GP2Y0A02YK 
- Arduino UNO (other models also are fine) × 1 + power cable (sold seperately)
- Dupont jumper wires Male - male
- Capacitor(≥10 µF)
- breadboard

Solder some male jumper wires on the cable that comes with the sensor for easy connection to arduino or breadboard.

2 Assembly

Connect the parts according this schematic:

SHARP-GP2Y0A21YK0F_bb.png
These type of distance sensors tend to be a bit noisy, so it is recommended to add a capacitor between Vcc and GND. The datasheet suggests a capacitor of 10 µF or more (I used 220 µF). Connect the positive lead of the capacitor to the Vcc wire connection and the negative lead to the GND wire connection (see picture). Capacitors are often marked with a stripe which indicates the negative lead. The positive lead is often longer then the negative lead.

3 Software & code

 Download the SharpIR library written by Guillaume Rico and Thibaut Mauon here.
For more information check the github page here.
This library is not available through the library manager of Arduino. You have to manually instal it. For how to manually installing a library check this page. Scroll down to: "Importing a .zip Library"

I've edited the code from the source website a little so you only get values and no text as output. Works better with visual programming software like Isadora or touchdesigner.

Copy this code into a new empty file, connect with your arduino and uplaod the code.

/*SHARP GP2Y0A21YK0F IR distance sensor with
Arduino and SharpIR library example code.
More info: https://www.makerguides.com */

// Include the library:
#include "SharpIR.h"

// Define model and input pin:
#define IRPin A0
#define model 1080

// Variable to store the distance
int distance_cm;

/* Model :
GP2Y0A02YK0F --> 20150
GP2Y0A21YK0F --> 1080
GP2Y0A710K0F --> 100500
GP2YA41SK0F --> 430
*/

// Create a new instance of the SharpIR class:
SharpIR mySensor = SharpIR(IRPin, model);

void setup() {
// Serial communication at a baudrate of 9600
Serial.begin(9600);
}

void loop() {
// Get a distance measurement and store it as distance_cm
distance_cm = mySensor.distance();

// Print the measured distance to the serial monitor

Serial.print(distance_cm);
Serial.println(" ");

delay(1000);
}

4 Connect the arduino to your computer. 

Connect Arduino to your computer & Upload the code.
If you do not know how to upload a Arduino sketch, please visit https://www.arduino.cc/en/Guide/Windows for Windows user or https://www.arduino.cc/en/Guide/MacOSX for Mac user.

Open the serial monitor by clicking the Magnifying glass in the top right corner of the window.

You should now see a stream of data measuring the distance to the object in front of the sensor. Hold your hand in front of the sensor and move it.

For connecting with Isadora read this

You can borrow this sensor for testing at the Blackbox location IBB. Contact: blackbox.ibb-pastoe@hku.nl

source: 
https://www.makerguides.com/sharp-gp2y0a21yk0f-ir-distance-sensor-arduino-tutorial/

Online electronic stores

Online stores