Framer is a flexible web-based tool that can allow your prototypes to talk directly to a connected device. By starting a server on your computer you can connect to a socket server in a few different ways—locally on your computer, over a local-network, or within Framer. This capability makes it possible to work with Arduino, RaspberryPI, or any other IoT device.
You can connect to an external device is through USB, Bluetooth, or HTTPS. In this guide, we’ll be connecting to the Arduino via USB and using HTTPS to connect to our web sockets. HTTP support is not possible.
We’ll show you how to work with an Arduino in both communication directions.
- Arduino sending a command to Framer to trigger an animation
- Framer sending a command to the Arduino to blink a light
Here are the steps to make an Arduino communicate with a Framer prototype.
- Set up your Arduino board and connect it to your computer using the cable.
- By following the example below you’ll create a loop from your Framer prototype to your Arduino. The button on the breadboard can trigger an animation in your prototype and your prototype can toggle the LED on and off.
- Open the terminal on your computer.
- You can use this template to get a headstart. Open this folder in your code editor.
yarn installin your code editor's terminal (ensure you have yarn installed on your computer)
yarn startto start your socketio server.
- Open this example project in Framer if you don't have it open already.
- Once your Framer project is ready, preview it alongside your local server console from earlier. If all is working as expected, you should see a line that says “Connected to Framer”.
- Preview the frame on the canvas and toggle the first item.
- You should be able to click your component and see your Arduino light up. Pressing the button connected to the Arduino should toggle your light again and reflect that state in your prototype.
- Now you have basic two-way communication working between your Arduino and Framer. You can add functionality to either side to create limitless hardware-based prototypes.