Neopixel, Fan, and Potentiometer

Greetings,
I have a project that I am working on and need some assistance. I am very new to Arduino/coding, and was looking to add a couple to my custom built co2 laser cutter. I have three different things I am trying to do not sure if they can be done on one Arduino or not. The first thing I would like to do is control a 3 pin 12 volt fan with a potentiometer, but at the same time have a neopixel 8 led strip that shows the amount the fan is at power wise (like a power reader). I would also like help with getting to do the power reader separate too please. The last thing I would like to do is control a couple of neopixel with a latching button push. I would like for when you power the Arduino the neopixel starts off red, when you push the latching button it turns from red to green. The second function I am looking to do when I push this other button (this one would be like an over write for the whole thing) it makes the light flicker between red and green. I would be looking for a schematic and code on for this matter please, any help is appreciated (good or bad lol).
Thanks in advance,
Zim

Everybody is born that way. Learning coding is necessary. No chance without that.
Start playing with the Arduino using IDE example files, learn and get accustomed. Put this project back to the shelf until You have warmed up.

You will find many tutorials online, some good some not so good. Start with drawing a Schematic. and add one function at a time. A simple one to start with is connecting a pot 1-10K. The end pins will go to the 5V and Ground. The center pin, the wiper will go to A0. Now write some code or you can find it on line and read the potometer and print on the console the value. Have this loop repeat every 10 seconds. Start with the delay, when that is working do it again by replacing the delay with the mills function. Next work with the map() function and have it print 0% to 100% on the console. This may take you two weeks a few hours each day. If you get in less time you are doing very good. If you have any questions feel free to ask. For this you will need a potometer, a prototype board and some jumpers. If you can afford it get an inexpensive multimeter, you will need it later. Also you can get a 24Mhz logic analyzer for less then $10.00 This will get you set up for a lot of fun and experimenting. Remember rule #1. The Arduino a Power Supply it is not. An additional 5V and 12V power suplys (wall warts work ok) will be needed later.

Hello,
I tried to use some code I found from adafruit, I was able to modify it to give me the button LED status I am looking for except for one issue. When I flick the switch it makes the color change , and when I hit the other button it changes the color too (so far so good). the issue with this I would like the second button to almost like be a constant loop until unpressed (latching switch). As stated above I am fairly new to this, but if there is any direction I can be pointed to that would be great.

P.S I am now sure how to upload my code if it is needed sorry.

Thanks In Advance,
Zim

Please read the forum introductory threads, there is a section there to explain how.

// Simple demonstration on using an input device to trigger changes on your
// NeoPixels. Wire a momentary push button to connect from ground to a
// digital IO pin. When the button is pressed it will change to a new pixel
// animation. Initial state has all pixels off -- press the button once to
// start the first animation. As written, the button does not interrupt an
// animation in-progress, it works only when idle.

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>  // Required for 16 MHz Adafruit Trinket
#endif

// Digital IO pin connected to the button. This will be driven with a
// pull-up resistor so the switch pulls the pin to ground momentarily.
// On a high -> low transition the button press logic will execute.
#define BUTTON_PIN1 A2
#define BUTTON_PIN2 A0

#define PIXEL_PIN 6  // Digital IO pin connected to the NeoPixels.

#define PIXEL_COUNT 2  // Number of NeoPixels

// Declare our NeoPixel strip object:
Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, NEO_GRB + NEO_KHZ800);
// Argument 1 = Number of pixels in NeoPixel strip
// Argument 2 = Arduino pin number (most are valid)
// Argument 3 = Pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
//   NEO_RGBW    Pixels are wired for RGBW bitstream (NeoPixel RGBW products)

boolean oldState1 = HIGH;
boolean oldState2 = HIGH;
int mode = 0;  // Currently-active animation mode, 0-9

void setup() {
  pinMode(BUTTON_PIN1, INPUT_PULLUP);
  pinMode(BUTTON_PIN2, INPUT_PULLUP);
  strip.begin();  // Initialize NeoPixel strip object (REQUIRED)
  strip.setPixelColor(0, 255, 0, 0);
  strip.show();
}

void loop() {
  // Get current button state.
  boolean newState1 = digitalRead(BUTTON_PIN1);
  boolean newState2 = digitalRead(BUTTON_PIN2);

  // Check if state changed from high to low (button press).
  if ((newState1 == LOW) && (oldState1 == HIGH)) {
    // Short delay to debounce button.
    delay(20);
    // Check if button is still low after debounce.
    newState1 = digitalRead(BUTTON_PIN1);
    if (newState1 == LOW) {      // Yes, still low
      if (++mode > 1) mode = 0;  // Advance to next mode, wrap around after #8
      switch (mode) {            // Start the new animation...
        case 0:
          colorWipe(strip.Color(255, 0, 0), 50);  // Red
          break;
        case 1:
          colorWipe(strip.Color(0, 255, 0), 50);  // Green
          break;
      }
    }
  }
  if ((newState2 == LOW) && (oldState2 == HIGH)) {
    // Short delay to debounce button.
    delay(20);
    // Check if button is still low after debounce.
    newState2 = digitalRead(BUTTON_PIN2);
    if (newState2 == LOW) {      // Yes, still low
      if (++mode > 0) mode = 0;  // Advance to next mode, wrap around after #8
      switch (mode) {            // Start the new animation...
        case 0:
          theaterChase(strip.Color(127, 0, 0), 50);  // Red
          break;
      }
    }
  }
  // Set the last-read button state to the old state.
  oldState1 = newState1;
  oldState2 = newState2;
}

// Fill strip pixels one after another with a color. Strip is NOT cleared
// first; anything there will be covered pixel by pixel. Pass in color
// (as a single 'packed' 32-bit value, which you can get by calling
// strip.Color(red, green, blue) as shown in the loop() function above),
// and a delay time (in milliseconds) between pixels.
void colorWipe(uint32_t color, int wait) {
  for (int i = 0; i < strip.numPixels(); i++) {  // For each pixel in strip...
    strip.setPixelColor(i, color);               //  Set pixel's color (in RAM)
    strip.show();                                //  Update strip to match
    delay(wait);                                 //  Pause for a moment
  }
}

// Theater-marquee-style chasing lights. Pass in a color (32-bit value,
// a la strip.Color(r,g,b) as mentioned above), and a delay time (in ms)
// between frames.
void theaterChase(uint32_t color, int wait) {
  for (int a = 0; a < 10; a++) {   // Repeat 10 times...
    for (int b = 0; b < 3; b++) {  //  'b' counts from 0 to 2...
      strip.setPixelColor(0, 255, 0, 0);
      // 'c' counts up from 'b' to end of strip in steps of 3...
      for (int c = b; c < strip.numPixels(); c += 3) {
        strip.setPixelColor(c, color);  // Set pixel 'c' to value 'color'
      }
      strip.show();  // Update strip with new contents
    }
  }
}

Hold on, are the red/green indicators separate from the 8 LED bar, or part of it? Where is the wiring diagram?

Yes, these are single neopixles, I am using for this part. Had three different codes I wanted combined then realized its probably better to have them separate.

Yes, how is everything wired? No words please.

sorry what is the best way for me to get you the diagram (not sure how to)

Use a pen and paper, take a picture and post it. Also:
"Please read the forum introductory threads, there is a section there to explain how."

Your "2 pos switch" can't be right. The way you show it, it would always be closed. I see only 2 pixels, where are the other 8? You have no capacitor or resistor on the Neo strip, that is common practice.

Does the E-stop control any device that can cause injury or death? Anything like that should be hard wired, not under software control.

it has two contacts on it a nc side and a no side
(Amazon.com)

Right, a SPDT, "single pole double throw".

Please re-draw your schematic, using conventional symbols instead of boxes that everyone can debate. When you do, also put labels exactly next to what they signify, not just nearby. Label all input/outputs to a device.

If you've even glanced at any electronic diagrams, I am sure you know how a switch is drawn.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.