Firefly – Extrude 3D Model with Joystick & LDR
A demonstration of how to extrude a 3D rhino model using a joystick or LDR (light sensor) connected to an arduino through grasshopper / firefly. This demo shows how to create a basic shape to extrude in Rhino and highlights the name of the modules used. In example 1 the analog joystick output is remapped (remap numbers module) from 0-1023 (analog range) to an appropriate value for the extrusion (0-100). The remapped value is run through an integer module to remove decimals and then into a unit Z module which turns the value into a direction vector. This vector goes into an extrude module along with the rhino shape to be extruded (linked to the curve module) and a surface module. Example 2 is similar except the LDR analog output is remapped differently which will depend on your particular LDR module and the light levels you want to respond to. To determine the source values being fed into the remap module, alter the environment to the darkest level you want to measure and take note of the analog value. Do the same again for the brightest level you want to measure, these two measurements will form the upper and lower range to input. [Note: Change the video quality to 1080p if you are having difficulty making out details]
WIRING & RHINO MODEL / GRASSHOPPER CODE
Example 1 Joystick module KY-023 – these contain 2 analog potentiometers (X axis and Y axis) and a button. The axis have a continous analog output (0 – 5V) and are read as values 0 – 1023 by the Arduino. [Joystick GND → GND, (+) → +5V, VX → A0] Example 2 LDR module KY-018 – this is a light level sensor that uses a light dependent resistor (LDR or photoresistor) to output different voltages depending on ambient light levels. The arduino anlog inputs will read values 0 – 1023 depending on the LDR module and light levels. Note: non-module versions of an LDR will require a pull-down resistor. [LDR module S → A0, Pin2 → +5V, (-) → GND]
This is the Rhino & Grasshopper code in action. As the analog input value changes it is transformed via the remap module into a more suitable value that then affects the extrusion height of the cyclinder.