Go Down

Topic: NEOPIXEL AND LOAD SENSOR HELP (Read 71 times) previous topic - next topic

21hollih

 I am working on a project including a load sensor and HX711 load cell amplifier so that when a certain weight is placed on it, the neopixel ring either lights up red or green.

The load sensor is working and so is the neopixel ring, separately. When I try to use them together, the Neopixel turns on, but never changes color when I add different weights.

I am struggling with my if/for statements and would love to hear your input/solutions, as this project must be finished by next week.

Thanks for all of your help!

DrAzzy

#1
Dec 13, 2018, 08:35 pm Last Edit: Dec 13, 2018, 08:36 pm by DrAzzy
When posting code, put it inline using code tags ( </> button), instead of attaching the sketch. That way we don't have to download it - particularly since many of us post from cellphones where downloading and opening a sketch is obnoxious. I still haven't figured out how to associate .ino with a text editor so I can view them on my phone.

Your problem is that you have scale.get_units() in quotes when you're testing it. Remove those quotes, and it should work.

Also, switch the for and if statements, ie,

if (scale.get_units > 3) {
for (byte i = 0;i<NUMPIXELS;i++) {pixels.setPixelColor(i,255,0,0);}
pixels.show();
} else if (...)

That way you're not reading the scale for every pixel.

Also, you realize that if the reading is under 1, nothing will happen, and the colors will not be changed - is that intended?
ATtiny core for 841+1634+828 and x313/x4/x5/x61/x7/x8 series Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts (some assembled), mosfets and awesome prototyping board in my store http://tindie.com/stores/DrAzzy

Go Up