Things used in this project

Hardware components:
Punch Through LightBlue Bean+
SeeedStudio Grove Rotary Angle Sensor
SeeedStudio Grove LED Bar
Software apps and online services:
Ide web
Arduino IDE
Punch Through Bean Loader


Grove LED Bar with Rotary ControllerArduino
#define ROTARY_ANGLE_SENSOR A3 // The input pin used for the sensor
#define ADC_REF 5 // This matches the operating voltage we set to 5V
#define GROVE_VCC 5 // VCC of the grove interface which is often 5V
#define NUM_OF_LEDS 10 // Number of LEDs in the LED bar

#include <Grove_LED_Bar.h>

Grove_LED_Bar LEDbar(A4, A5, 1); // Setting the data and clock pins used

void setup() 

void loop() 
  // Measure the number of LEDs that should be on
  // based on the angle of the rotary sensor
  int lightLevel = getLightLevel();

  // If light level is above 0, set LED bar accordingly
  if (lightLevel) {
    // Turn on the LEDs up to the measured light level
    for (int i = 1; i <= lightLevel; i++) {
        // Turn on 
        LEDbar.setLed(i, 1);
    // Turn off the rest of the LEDs in reverse order
    for (int j = 10; j > lightLevel; j--) {
        // Turn off 
        LEDbar.setLed(j, 0);
  } else {
    // Turn off all LEDs 
    for (int k = 1; k <= 10; k++) {
        // Turn off
        LEDbar.setLed(k, 0);

int getLightLevel()
  // Take reading, measure voltage, and calculate 
  // number of LEDs which should be turned on
  int reading = analogRead(ROTARY_ANGLE_SENSOR); 
  float voltage = (float)reading*ADC_REF/1023;
  float level = (voltage*NUM_OF_LEDS)/GROVE_VCC;
  return level;


Karel Kalthoff

happily building connected products at Punch Through Design



Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback


Similar projects you might like

    Get Notified When Door Is Unlocked: LightBlue Bean/Node-Red
    • 291
    • 2

    Full instructions

    Get notifications by email when your door has been unlocked.

    Electronic Egg Toss Game
    • 618
    • 13

    The classic picnic game is messy, but this version will let you practice indoors.

    Bluetooth RC
    • 992
    • 15

    Work in progress

    RC car controlled using BLE.

    Hypnos Pendant
    • 1,842
    • 12

    Full instructions

    A wearable that promotes mindfully spending your time, which also helps trigger lucid dreams.

    LightBlue Bean: Arduino Basics
    • 1,286
    • 15


    This little Bluetooth board is ideal for wearable tech and tiny robots. Get started with these projects!

    Getting Started with Bluetooth Low Energy (BLE)
    • 5,136
    • 18


    In this tutorial, we'll learn how to set up BLE GATT services to make a thermometer using Intel's Arduino 101

    Add projectSign up / Login