There has been a few comments about the drawing. Its drawn with Paint with a size of 1776X928 pixels. This looks clear to me. But OK. Will do next time. BTW it is NOT Fuzzy.
Hi DaveEvans.
Both the RPM and the Thrust are working fine before combining the code.
The Load cell code.
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SH110X.h>
#include "HX711.h"
#define DOUT 4
#define CLK 3
HX711 scale(DOUT, CLK);
float weight;
float calibration_factor = 676750; // for me this value works just perfect
/* Uncomment the initialize the I2C address , uncomment only one, If you get a totally blank screen try the other*/
#define i2c_Address 0x3c //initialize with the I2C addr 0x3C Typically eBay OLED's
//#define i2c_Address 0x3d //initialize with the I2C addr 0x3D Typically Adafruit OLED's
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET -1 // QT-PY / XIAO
Adafruit_SH1106G display = Adafruit_SH1106G(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
#define LOGO16_GLCD_HEIGHT 16
#define LOGO16_GLCD_WIDTH 16
static const unsigned char PROGMEM logo16_glcd_bmp[] =
{ B00000000, B11000000,
B00000001, B11000000,
B00000001, B11000000,
B00000011, B11100000,
B11110011, B11100000,
B11111110, B11111000,
B01111110, B11111111,
B00110011, B10011111,
B00011111, B11111100,
B00001101, B01110000,
B00011011, B10100000,
B00111111, B11100000,
B00111111, B11110000,
B01111100, B11110000,
B01110000, B01110000,
B00000000, B00110000
};
void setup() {
Serial.begin(57600);
scale.set_scale();
//scale.tare(); //Reset the scale to 0
long zero_factor = scale.read_average(); //Get a baseline reading
delay(250); // wait for the OLED to power up
display.begin(i2c_Address, true); // Address 0x3C default
//display.setContrast (0); // dim display
display.display();
delay(2000);
// Clear the buffer.
display.clearDisplay();
}
void loop() {
scale.set_scale(calibration_factor); //Adjust to this calibration factor
display.display();
delay(1000);
display.clearDisplay();
display.setCursor(0, 25);
display.setTextSize(1);
display.setTextColor(SH110X_WHITE);
display.print("Reading: ");
weight = scale.get_units(5);
display.print("Kg ");
display.print(weight);
delay(10);
}
And the IR code.
#include <Arduino.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SH110X.h>
#define i2c_Address 0x3c //initialize with the I2C addr 0x3C Typically eBay OLED's
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET -1 // QT-PY / XIAO
Adafruit_SH1106G display = Adafruit_SH1106G(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
#define LOGO16_GLCD_HEIGHT 16
#define LOGO16_GLCD_WIDTH 16
unsigned long rpmtime;
float rpmfloat;
unsigned int rpm;
bool tooslow = 1;
void setup() {
Serial.begin(9600);
display.begin(i2c_Address, true); // Address 0x3C default
display.display();
delay(2000);
// Clear the buffer.
display.clearDisplay();
TCCR1A = 0;
TCCR1B = 0;
TCCR1B |= (1 << CS12); //Prescaler 256
TIMSK1 |= (1 << TOIE1); //enable timer overflow
pinMode(2, INPUT);
attachInterrupt(0, RPM, FALLING);
}
ISR(TIMER1_OVF_vect) {
tooslow = 1;
}
void loop() {
display.display();
delay(1000);
display.clearDisplay();
display.setCursor(0, 0);
display.setTextSize(2);
display.setTextColor(SH110X_WHITE);
if (tooslow == 1) {
display.print("Too Slow");
}
else {
rpmfloat = 120 / (rpmtime/ 31250.00);
rpm = round(rpmfloat);
display.print("RPM = ");
display.setCursor(0, 15);
display.print(rpm);
}
}
void RPM () {
rpmtime = TCNT1;
TCNT1 = 0;
tooslow = 0;
}
Johnerrington.
The power supply does have a decoupling circuit in.
Thanks for the inputs.
Regards.