Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "HX711.h"
- #include <FastLED.h>
- #define bits 64
- HX711 scale5(2, 9, bits);
- HX711 scale6(3, 9, bits);
- HX711 scale7(4, 9, bits);
- float a, b, c;
- float var = 12.0f;
- bool touch = false;
- #define LED_PIN 5
- #define NUM_LEDS 12
- CRGB leds[NUM_LEDS];
- void setup() {
- Serial.begin(38400);
- scale5.set_scale(2280.f);
- scale5.tare();
- scale6.set_scale(2280.f);
- scale6.tare();
- scale7.set_scale(2280.f);
- scale7.tare();
- FastLED.addLeds<WS2812B, LED_PIN, RGB>(leds, NUM_LEDS);
- }
- void loop() {
- a = scale5.get_units(1);
- b = scale6.get_units(1);
- c = scale7.get_units(1);
- if (abs(a) > var or abs(b) > var or abs(c) > var){
- touch = true;
- }
- else{
- touch = false;
- }
- if (touch){
- for(int i = 0; i < NUM_LEDS; i++){
- leds[i] = CRGB(255, 255, 255);
- }
- }
- else{
- for(int i = 0; i < NUM_LEDS; i++){
- leds[i] = CRGB(0, 0, 0);
- }
- }
- FastLED.show();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement