I want to build a circuit on Arduino uno R3 and I am having a struggle with programing it. The circuit includes potentiometer, LED RGB STRIPES ws2813 and DC motor. Everything depending on potentiometer, speed of rotation, color of leds (it should go from green through orange to red). Also I want that leds to pulse. Can anyone help me? I am really lost.
Where exactly are you lost? Please post details of your project, and the code.
best if you begin on basics.
Hello michal123456
Welcome to the worldbest Arduino forum ever.
This is a nice project to get started.
Keep it simple and stupid firstly.
Follow the example code that comes with the library or
run some tutorials for the hardware selected.
If you are happy with the results of the tutorials you can merge these to your project.
Have a nice day and enjoy coding in C++.
OOPS! I did not mean to repy to aarg, but to the OP.
There is no shortage of members willing to help. There is a shortage of information that we can use to help you, though.
Please read the forum guidelines to see how to properly post code and some information on making a good post.
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in a code block.
Please post the code that you have tried. Tell us what the code actually does and what the code should do.
It would be helpful if you post a schematic or wiring diagram and photos of your wiring, too.
#include <Adafruit_NeoPixel.h>
#define LED_COUNT 18
#define LED_PIN 6
Adafruit_NeoPixel strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
#define p1 A0
int pot1;
int motor = 3;
void setup() {
strip.begin();
pinMode(motor, OUTPUT);
strip.show();
Serial.begin(115200);
}
void loop() {
pot1 = analogRead(p1);
analogWrite(motor, map(pot1, 0, 1023, 0, 255));
int redValue = 0;
int greenValue = 0;
int blueValue = 0;
int adjustedPotValue = map(pot1, 0, 1023, 0, 255);
adjustedPotValue = map(adjustedPotValue, 0, 255, 0, 170);
if (adjustedPotValue < 85) {
redValue = 0;
greenValue = adjustedPotValue * 3;
} else if (adjustedPotValue < 170) {
adjustedPotValue -= 85;
redValue = adjustedPotValue * 3;
greenValue = 255 - adjustedPotValue * 3;
} else {
adjustedPotValue -= 170;
redValue = 255;
greenValue = adjustedPotValue * 3;
}
for (int i = 0; i < LED_COUNT; i++) {
setPixel(i, redValue, greenValue, blueValue);
}
strip.show();
delay(50);
}
void setPixel(int pixel, int red, int green, int blue) {
strip.setPixelColor(pixel, strip.Color(red, green, blue));
}
I managed to write some code from yt videos and with help from OpenAI. This code only changes colors and speed of rotation via potentiometer, but I want to add pulsating effect that is also connected to potentiometer. Do you know how to do it? Thanks for help
Look up PWM dimming ...
Also, youll need to power the stuff separately from the Arduino. You cannot draw much current from the +5V pin.
HI, @michal123456
Welcome to the forum.
Can we please have a circuit diagram?
An image of a hand drawn schematic will be fine, include ALL power supplies, component names and pin labels.
Can you please post some images of your project so we can see your component layout?
You cannot power/control a motor directly from an I/O pin of a microcontroller.
Thanks... Tom...
Ok i will look it up thanks. What kind of energy supply would you recommend for 3m of led stripe which includes 432 leds if its real.
I want to use this motor https://www.adafruit.com/product/4641. Then i know i need some resistors and capacitors but dont know which ones to use. I need to figure out the supply of energy.
Thanks for help
now you see that capacitor is shorted. that is why we asking always the schematic.
the motor need 6V
Hi,
No load <=45mA, that is too much to draw from the controller.
Stall Current, which is also the starting current = 0.2A or 200mA, way too much for the controller.
Look at the graphic on that page.
You will not need something as big as that, but depending if you want to change direction, you can just use a MOSFET or BJT to power/control your motor.
Tom..
#include <Adafruit_NeoPixel.h>
#define LED_COUNT 18
#define LED_PIN 6
Adafruit_NeoPixel strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
#define p1 A0
int pot1;
int motor = 3;
void setup() {
strip.begin();
pinMode(motor, OUTPUT);
strip.show();
Serial.begin(115200);
}
void loop() {
pot1 = analogRead(p1);
analogWrite(motor, map(pot1, 0, 1023, 0, 255));
int redValue = 0;
int greenValue = 0;
int blueValue = 0;
int adjustedPotValue = map(pot1, 0, 1023, 0, 255);
adjustedPotValue = map(adjustedPotValue, 0, 255, 0, 170);
if (adjustedPotValue < 85) {
redValue = 0;
greenValue = adjustedPotValue * 3;
} else if (adjustedPotValue < 170) {
adjustedPotValue -= 85;
redValue = adjustedPotValue * 3;
greenValue = 255 - adjustedPotValue * 3;
} else {
adjustedPotValue -= 170;
redValue = 255;
greenValue = adjustedPotValue * 3;
}
for (int i = 0; i < LED_COUNT; i++) {
setPixel(i, redValue, greenValue, blueValue);
}
strip.show();
delay(50);
}
void setPixel(int pixel, int red, int green, int blue) {
strip.setPixelColor(pixel, strip.Color(red, green, blue));
}
First thing that i want to make is 100% working program, then I want too choose right components(That is another long story . The only thing that I am missing in this code is to make these LEDs pulse. I want to make this pulsing constant for every speed (rpm). I found on the internet only PWM bidding which depends to potentiometer. If anyone can help, I will be thankful.
What kind of controller would you recommend?
Almost sounds like a project for
Introducing ChatGPT (openai.com)
You can go from an example code chat gpt gives you and learn the basics from there.
Please, no. Such AI can't even properly learn from humans, how do you think a human could learn from it? World class bad advice. Arduino (and many others) spent a lot of thoughtful time creating a myriad of tutorials and reference material. What is so hard about learning from those?
AI written code is usually complete garbage.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.