Skip to content

tutorial donut counter

Ken Sharp edited this page Dec 11, 2025 · 1 revision

LabVIEW Donut Counter on LINX

Bring a little fun to your makerspace by deploying the lv-donut-counter application to a BeagleBone Black. A photocell inside a donut box detects when the lid opens, decrements a counter, and publishes the remaining donut count to a LabVIEW Web Service that you can view from any browser.

Donut counter overview

Prerequisites

  • LabVIEW Community Edition (or LabVIEW 2020+) with the LabVIEW Hobbyist Toolkit installed.
  • LINX package deployed to your BeagleBone Black target.
  • Basic familiarity with deploying VIs from the Blink! and Startup Executable tutorials.

Hardware

  • BeagleBone Black configured for LINX.
  • Photocell (CdS) light sensor positioned inside the donut box.
  • 10 kΩ resistor to create a voltage divider with the photocell.
  • LED indicator (optional) to show donut availability.
  • Jumper wires, breadboard, and USB/network connectivity for the BeagleBone Black.

📷 Need wiring guidance? Reference the circuit diagram included in the repository: Circuit diagram

Software Assets

  • Clone or download the project: git clone https://github.com/sharpk/lv-donut-counter.git
  • Key LabVIEW files:
    • donut_counter.lvproj – main project with the BeagleBone Black target.
    • main.vi – top-level VI that monitors the photocell and updates the donut count.
    • GetCount.vi / SetCount.vi – Web Service method VIs used to read or set the count remotely.
    • www/donut.html – browser UI that polls the Web Service to display the remaining donuts.

Build & Deploy Steps

  1. Open the project – Launch donut_counter.lvproj and connect to your BeagleBone Black target inside the Project Explorer.
  2. Review the shared variables – Global.vi holds the donut count. Familiarize yourself with how main.vi decrements the value each time the photocell toggles.
  3. Wire the photocell – Create a voltage divider between 3.3 V and ground, routing the midpoint to one of the BeagleBone analog inputs (e.g., AIN0). Update the channel constant in main.vi if you choose a different input.
  4. Deploy the Web Service – Under the Web Service build specification, ensure GetCount.vi and SetCount.vi are mapped to /ws/GetCount and /ws/SetCount. Build and deploy so the target can respond to HTTP requests.
  5. Serve the dashboard – Copy the www/ folder to the target’s /srv/http/ (or include it inside the Web Service public content) so donut.html is reachable at http://<target-ip>/ws/donut.html.
  6. Run the application – Deploy main.vi or build it as a startup executable so the donut count logic runs whenever the BeagleBone boots.
  7. Test the workflow – Open the donut box to trigger the photocell. The donut count should decrement. Visit /ws/GetCount to see the JSON response or use donut.html for a friendlier UI. Reset the count via /ws/SetCount?count=12 when you restock.

Application Site Map

  • /ws/donut.html – main donut dashboard served by the target.
  • /ws/GetCount – returns { "count": <value> } for polling clients.
  • /ws/SetCount?count=<n> – updates the shared donut count when you refill the box.

Related Links

Clone this wiki locally