Jeren Arellano Reeder
Published

Dyna-Mator

A small Truck model with OLED eyes thats able to measure its internal RPM's and change the rooms lights based on Speed.

BeginnerWork in progress20 hours25
Dyna-Mator

Things used in this project

Hardware components

Hall Effect Sensor
Hall Effect Sensor
×1
SparkFun Atmospheric Sensor Breakout - BME280
SparkFun Atmospheric Sensor Breakout - BME280
×1
OLED Expansion
Onion Corporation OLED Expansion
×2
Photon
Particle Photon
×1
intercooling fan
×1

Software apps and online services

Photon 2

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)
Laser cutter (generic)
Laser cutter (generic)

Story

Read more

Custom parts and enclosures

Truck files

Solidwork Truck files and Assembly

Code

Dyna-Mator

C/C++
A truck controller made to control the Room based off RPMS.
/* 
 * Project: DYNOMOTOR
 * Author: Jeren A Reeder
 * Date: 6/30/25
 * For comprehensive documentation and examples, please visit:
 * https://docs.particle.io/firmware/best-practices/firmware-template/
 */

// Include Particle Device OS APIs
#include "Particle.h"
#include "Adafruit_GFX.h"
#include "Adafruit_SSD1306.h"
#include "Adafruit_BME280.h"
#include "IoTClassroom_CNM.h"
#include "Button.h"
#include "hue.h"
const int OLED_RESET=-1;
Adafruit_SSD1306 display1(OLED_RESET);
Adafruit_SSD1306 display2(OLED_RESET);
SYSTEM_MODE(MANUAL);
char number = 164;

// button

//SYSTEM_THREAD(ENABLED);
//SerialLogHandler logHandler(LOG_LEVEL_INFO);

/**
 * Made with Marlin Bitmap Converter
 * https://marlinfw.org/tools/u8glib/converter.html
 *
 * This bitmap from the file 'car eye (4).jpg'
 */
#pragma once

#define ETJBIA_BMPWIDTH  128
#define ETJBIA_BMPHEIGHT 64

const unsigned char bitmap_etjbia[] PROGMEM = {
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x03,0xFF,0xFF,0xFF,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00,0x00,0x00,0x00,
  0x00,0x07,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,0x00,0x00,0x00,
  0x00,0x1F,0xFF,0xFF,0xFF,0xF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,0xFF,0xFF,0xFF,
  0xFF,0xFF,0xFF,0xF3,0xF7,0xF8,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  0xFF,0xFF,0xFF,0xFC,0xFF,0xFE,0xC0,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  0xFF,0xFF,0xFF,0xFE,0x7F,0x78,0x80,0x07,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  0xFF,0xFF,0xFF,0xFF,0xC7,0xB0,0x80,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  0xFF,0xFF,0xFF,0xFF,0xF8,0x24,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
};

/**
 * Made with Marlin Bitmap Converter
 * https://marlinfw.org/tools/u8glib/converter.html
 *
 * This bitmap from the file 'car eye left (4).jpg'
 */
#pragma once

#define FQYNRH_BMPWIDTH  128
#define FQYNRH_BMPHEIGHT 64

const unsigned char bitmap_fqynrh[] PROGMEM = {
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0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,0xFF,0xFF,
  0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x1F,0xFF,0xFF,0xFF,0xFF,
  0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
};



const int hallPin = D13;
const int vibratePin = D19;
Button hallSensor(hallPin,true);
//Eye,Measurement button
const int buttonPin = D2;
Button stopButton(buttonPin);  // true = active LOW 
bool isStopped = false; 
//Wemos with Addresses
const int MYWEMO=0; 
const int MYWEMO1=1; 
const int MYWEMO2=2;
//const int MYWEMO1=3; 3rd wemo not active
const int MYWEMO4=4;
const int MYWEMO5=5;
//RPS And RPM 
const int ROTATIONS = 20;
int inputValue; 
int prevState = HIGH;
int rotationCount = 0;
int lastSecond = 0;
int lastRotationTime = 0;
int count = 0;
int startTime;
int endTime;
int RPM;
int RPS;
//BME 
Adafruit_BME280 bme;
int hexAddress = 0x76;
float temp,Fahrenheit;
bool status;
//hue
bool onOFF;
const int brightness = 240;
const int saturation = 255;
const int BULB1=1; 
const int BULB2=2; 
const int BULB3=3; 
const int BULB4=4; 
const int BULB5=5; 
const int BULB6=6; 



void setup() {
  Serial.begin(9600);
  waitFor(Serial.isConnected, 5000);
   display1.begin(SSD1306_SWITCHCAPVCC, 0x3C); 
   display2.begin(SSD1306_SWITCHCAPVCC, 0x3D); 
     status = bme.begin(hexAddress);
       WiFi.on();
  WiFi.clearCredentials();
  WiFi.setCredentials("IoTNetwork");
  
  WiFi.connect();
  while(WiFi.connecting()) {
    Serial.printf(".");
  }
  Serial.printf("\nconnected\n");
  pinMode(hallPin, INPUT);
}
void loop() {
 
// OLED Eyes/RPM Switch using green Button
  if (stopButton.isClicked()) {
    isStopped = !isStopped;
    display1.clearDisplay();
    display2.clearDisplay();
    Serial.printf("%i\n",isStopped);
  }
    if (isStopped) {
      display1.drawBitmap(0, 0, bitmap_etjbia, 128,64,WHITE);
      display1.display();
      display1.clearDisplay();
      display2.drawBitmap(0, 0, bitmap_fqynrh, 128,64,WHITE);
      display2.display();
      display2.clearDisplay();
      Serial.println("Stopped RPM reading, showing bitmap.");
      return;  // skip the rest of loop
    } else {
      Serial.println("Resuming RPM reading.");
    
  }
// wemo lights if RPMS higher then 3500
  if (!isStopped) {
  Serial.printf("MagnetState=%i\n",inputValue);
  Serial.printf("RPS: %d\n", RPS);
  if (RPM > 3601){
    Serial.printf("Turning on Wemo# %i\n",MYWEMO);
    wemoWrite(MYWEMO,HIGH);
  }
  if (RPM < 3600){
    Serial.printf("Turning off Wemo# %i\n",MYWEMO);
    wemoWrite(MYWEMO,LOW);
  }
  //Second Wemo below
    if (RPM > 3701){
    Serial.printf("Turning on Wemo# %i\n",MYWEMO1);
    wemoWrite(MYWEMO1,HIGH);
  }
  if (RPM < 3700){
    Serial.printf("Turning off Wemo# %i\n",MYWEMO1);
    wemoWrite(MYWEMO1,LOW);
  } 
  //Third Wemo 
      if (RPM > 3701){
    Serial.printf("Turning on Wemo# %i\n",MYWEMO1);
    wemoWrite(MYWEMO2,HIGH);
  }
  if (RPM < 3700){
    Serial.printf("Turning off Wemo# %i\n",MYWEMO1);
    wemoWrite(MYWEMO2,LOW);
  } 
  //1st Light
     if (RPM > 3701){
     Serial.println(BULB1);
     setHue(BULB1,TRUE,HueRainbow[0],brightness, saturation);
   }
   if (RPM < 3700){
     Serial.println(BULB1);
     setHue(BULB2,TRUE,HueRainbow[2],brightness, saturation);
   }
   //2nd Light
     if (RPM > 3701){
     Serial.println(BULB2);
     setHue(BULB2,TRUE,HueRainbow[0],brightness, saturation);
   }
   if (RPM < 3700){
     Serial.println(BULB2);
     setHue(BULB2,TRUE,HueRainbow[2],brightness, saturation);
   }
   //3rd Light
        if (RPM > 3701){
     Serial.println(BULB3);
     setHue(BULB3,TRUE,HueRainbow[0],brightness, saturation);
   }
   if (RPM < 3700){
     Serial.println(BULB3);
     setHue(BULB3,TRUE,HueRainbow[2],brightness, saturation);
   }
   //4th Light
     if (RPM > 3701){
     Serial.println(BULB4);
     setHue(BULB4,TRUE,HueRainbow[0],brightness, saturation);
   }
   if (RPM < 3700){
     Serial.println(BULB4);
     setHue(BULB4,TRUE,HueRainbow[2],brightness, saturation);
   }
   //5th Light
        if (RPM > 3701){
     Serial.println(BULB5);
     setHue(BULB5,TRUE,HueRainbow[0],brightness, saturation);
   }
   if (RPM < 3700){
     Serial.println(BULB5);
     setHue(BULB5,TRUE,HueRainbow[2],brightness, saturation);
   }
        if (RPM > 3701){
     Serial.println(BULB6);
     setHue(BULB6,TRUE,HueRainbow[0],brightness, saturation);
   }
   if (RPM < 3700){
     Serial.println(BULB6);
     setHue(BULB6,TRUE,HueRainbow[2],brightness, saturation);
   }
  }

//timer + Equations used for converting RPS to RPM and Celsius to Fahrenheit formula
rotationCount = 0;
startTime = micros();

  while ( rotationCount < ROTATIONS) {
    if (hallSensor.isClicked()) {
      rotationCount++;
      Serial.printf(".");
    }
 
    endTime= micros();
    RPS = (ROTATIONS/((endTime-startTime)/1000000.0));
    RPM = (ROTATIONS/((endTime-startTime)/1000000.0)) * 60;
  
temp = bme.readTemperature();
Fahrenheit = (temp * 9/5) + 32;
}

//Displaying RPS, RPM, Temp, when button is clicked again and eyes disapear
  {
  display1.clearDisplay();
  //display1.drawBitmap(1, 1,bitmap_bqvuj ,128,64,WHITE);
  display1.display();
  display1.clearDisplay();
  display1.setTextSize(1);
  display1.setTextColor(WHITE);
  display1.setCursor(1,1);
  display1.setRotation(2);
  display1.printf("RPS: %d\nRPM: %d\nTemp: %0.1fF\n", RPS, RPM, Fahrenheit);
  display1.display();

  display2.clearDisplay();
//  display2.drawBitmap(1, 1,bitmap_bqvuj ,128,64,WHITE);
  display2.display();
  display2.clearDisplay();
  display2.setTextSize(1);
  display2.setTextColor(WHITE);
  display2.setCursor(1,1);
  display2.setRotation(2);
  display2.printf("RPS: %d\nRPM: %d\nTemp: %0.1fF\n", RPS, RPM, Fahrenheit);
  display2.display();
  }
}


  

Credits

Jeren Arellano Reeder
3 projects • 6 followers
Hardware engineer specializing in solidworks, embedded systems, circuit design, PCB layout, and integration for IoT.

Comments