fab-lab.eu
Published

Win the Challenge: How Can You Tune Your Fidget Spinner?!

Fidget Spinners are everywhere - one of the challenges is to get the fastest spinning and longest running Spinner...build a sensor!

BeginnerShowcase (no instructions)2 hours6,459
Win the Challenge: How Can You Tune Your Fidget Spinner?!

Things used in this project

Hardware components

#IoT OCTOPUS badge ESP8266-12F
or any ESP8266 board (see below)
×1
SparkFun Photo Interrupter - GP1A57HRJ00F
or CNY70 as reflection sensor, some folks are going to use a Laser (be careful) as well
×1
SparkFun Photo Interrupter Breakout Board - GP1A57HRJ00F
breakout borad for the sensor
×1
Adafruit 15x7 CharliePlex LED Matrix FeatherWing
optional if you like to have a display and no cloud ;-)
×1
Adafruit Feather HUZZAH with ESP8266 WiFi
Adafruit Feather HUZZAH with ESP8266 WiFi
also an optional board with ESP8266, need some wiring
×1
ESP8266 ESP-12E
Espressif ESP8266 ESP-12E
also an option if you like to add USB/LDO yourself
×1

Software apps and online services

Blynk
Blynk
quickly build an App for displaying the RPM

Story

Read more

Code

Spinner

Arduino
Arduino sketch for ESP8266 ... feeding RPM data into the Blynk APP, you can add easily a Adafruit Charlie Wing Matrix LED as output too ...
#define BLYNK_PRINT Serial    
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>

volatile byte rpmcount;
unsigned int rpm;
unsigned long timeold;
SimpleTimer timer; // Not used yet

char BlynkAuth[] = "YOUR BLYNK KEY";

char WiFiNetwork[] = "YOUR SSID";
char WiFiPassword[] = "YOUR WPA2 PASSKEY";

void myTimerEvent()
{
   // Not yet used
}

void rpm()
{
  rpmcount++;
}

void setup()
{
  Serial.begin(9600);
  // The Sensor is connected to ESP8266 GPIO4
  attachInterrupt(4,rpm,FALLING); // Connect SIG from sensor to PIN4
  rpmcount=0;
  rpm=0;
  timeold=0;
  // Connect to Blynk Cloud using Wifi
  Blynk.begin(BlynkAuth, WiFiNetwork, WiFiPassword);
  // Timer not yet used
  // timer.setInterval(1000L, myTimerEvent);
}

void loop()
{
   Blynk.run();

   // Update RPM every second, Interrupt can fire during this time
   delay(1000);
   // Stop Interrupt during calculation
   detachInterrupt(0);
   rpm=60/3*1000/(millis()-timeold)*rpmcount; // 3 = three arms
   timeold=millis();
   rpmcount=0;

   // Print out result to debug
   Serial.println(rpm);
   Blynk.virtualWrite(V5, rpm); // Send to Blynk App

   // Restart the Interrupt
   attachInterrupt(4,rpm,FALLING);
}

Credits

fab-lab.eu

fab-lab.eu

22 projects • 275 followers
Maker!

Comments