one single neopixel led with tmp36

Hello,

I'm looking for a better way to do a project with one single neopixel led and a temperature sensor.

I'm using:

  • micro arduino
  • tmp 36
  • one neopixel led
  • 3 resistances

I have done a similar project, but with 3 led. With some help from "TomGeorge (arduino forum)" I got it!

Now, I'm facing the neopixel code problem, always the code?!? For the first project I used this code:

int outputpin= 0;
int red = 7; // the pins for the LED
int green = 8;
int yellow = 9;
float celsiustemp = 0;
float cold = 28.0;
float hot = 30.0;
//this sets the ground pin to LOW and the input voltage pin to high
void setup()
{
pinMode(red, OUTPUT); // tell Arduino LED is an output
pinMode(green, OUTPUT);
pinMode(yellow, OUTPUT);
Serial.begin(9600);
}
//main loop
void loop()
{
int rawvoltage= analogRead(outputpin);
float volts= rawvoltage/205.0;
float celsiustemp= 100.0 * volts - 50;
Serial.print(celsiustemp);
Serial.println(" Celsius");
delay(5000);

allLedsOff();
if (celsiustemp >= hot) {
digitalWrite(red, HIGH);
} else if (celsiustemp <= cold){
digitalWrite(yellow, HIGH);
} else {
digitalWrite(green, HIGH);
}

} // end loop

void allLedsOff() {
digitalWrite(yellow, LOW);
digitalWrite(green, LOW);
digitalWrite(red, LOW);
}

Now, I need to insert the code for the neopixel... That's my main question?

Thank you. all the best,
ricardo

In that sketch you have probably used it for a 5050 RGB led with pins for R, G, and B led.

A NeoPixel is also a 5050 RGB led, but it has a extra controller inside. You start with the Adafruit_NeoPixel library or the FastLED library. If you open the Library Manager, you can find the Adafruit_NeoPixel there. Install it, and a few examples are added to the examples menu.

many thanks!

I'll try... after report the result

I have a single NeoPixel that shows the 'mood' of my Arduino, and I use the Adafruit library for just that one NeoPixel :stuck_out_tongue:

I also have neopixels but if you have a project that consists of a sensor and a single LED than you should probably consider using a RGB led instead of a 'LED pixel'. Driving the Neopixels at 800khz is guaranteed to cost you a lot of energy.

My personal find with neopixels is that your should regularly refresh the LEDs because the state of the LED between updates isn't very reliable over long periods of time.

just my 2cents