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