Advertisement
Guest User

Untitled

a guest
May 19th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1.  
  2. #include "HX711.h"
  3. #include <FastLED.h>
  4.  
  5. #define bits 64
  6.  
  7. HX711 scale5(2, 9, bits);
  8. HX711 scale6(3, 9, bits);
  9. HX711 scale7(4, 9, bits);
  10.  
  11. float a, b, c;
  12. float var = 12.0f;
  13.  
  14. bool touch = false;
  15.  
  16. #define LED_PIN 5
  17. #define NUM_LEDS 12
  18. CRGB leds[NUM_LEDS];
  19.  
  20. void setup() {
  21. Serial.begin(38400);
  22.  
  23. scale5.set_scale(2280.f);
  24. scale5.tare();
  25.  
  26. scale6.set_scale(2280.f);
  27. scale6.tare();
  28.  
  29. scale7.set_scale(2280.f);
  30. scale7.tare();
  31.  
  32. FastLED.addLeds<WS2812B, LED_PIN, RGB>(leds, NUM_LEDS);
  33. }
  34.  
  35. void loop() {
  36. a = scale5.get_units(1);
  37. b = scale6.get_units(1);
  38. c = scale7.get_units(1);
  39. if (abs(a) > var or abs(b) > var or abs(c) > var){
  40. touch = true;
  41. }
  42. else{
  43. touch = false;
  44. }
  45.  
  46. if (touch){
  47. for(int i = 0; i < NUM_LEDS; i++){
  48. leds[i] = CRGB(255, 255, 255);
  49. }
  50.  
  51. }
  52. else{
  53. for(int i = 0; i < NUM_LEDS; i++){
  54. leds[i] = CRGB(0, 0, 0);
  55. }
  56. }
  57.  
  58. FastLED.show();
  59.  
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement