Firefly – Serial Read Ultrasonic Sensor

Learn how to read serial data in Grasshopper / Firefly from an unsupported sensor connected to an Arduino. In this example an ultrasonic distance sensor (ping sensor) is used, but the same process could be applied to any sensor that requires a library and isn’t supported by Firefly. The values received from the serial read module are first stripped using a text split module to extract only the distance value. This value is then remapped (remap numbers module) to a value suitable for controlling a servo motor which is connected to a second Arduino through Firefly.   [Note: Change the video quality to 1080p if you are having difficulty making out details]  

WIRING & GRASSHOPPER CODE

Ultrasonic sensor HC-SR04 – this sensor uses 2 data pins, a trigger pin to send a ‘ping’ and an echo pin to listen for it’s return reflection (note: these sensors can also work with one data pin by linking the trigger and echo pin and using different code).  [Connect Vcc → 5V,  Gnd → GND,  Trig  D12,  Echo  D11]  Servo motor SG90 9g – servos have 3 wires, 2 for power and a single data pin. Note: the output pin on the Uno Write module needs to be set to ‘servo’.  [Servo  Red → 5VBrown → GNDOrange → D9]


 

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

ADDRESS

BRISBANE,
QLD, AUSTRALIA

CONTACT

NEWSLETTER

Sign up to recieve my newsletter