The project I'm working on is using an Arduino which will turn off and on LED strips based on user input over Bluetooth. The problem I've run into is that when I went from one LED to 2 my second one now does not turn off immediately when given the off command it instead takes about 20 seconds to slowly turn off (dims over time till fully turning off). But the first one still works correctly. The goal will be to add a couple more lights to this project so its important that I figure this issue out. I've taken some photos of the project and also tried to draw a sketch to give some clarity of what wires are where. Please let me know whatever thoughts you have.
Nice picture but I prefer a schematic, not a frizzy picture. Also post links to technical information on each of the hardware devices. Posting your code will help us help you. Follow the forum instructions when posting.
read about analogWrite()
Will definitely look into analogWrite() and see what I find.
(This is the code I'm currently running)
#include <SoftwareSerial.h>
//SoftwareSerial mySerial(2,3);
int ledpin=11;
int ledpin2=12;
int ledpin3=10;
void setup()
{
Serial.begin(9600);
Serial.begin(9600);
pinMode(ledpin,OUTPUT);
}
void loop()
{
int i;
if (Serial.available())
{
i=Serial.read();
Serial.println("DATA RECEIVED:");
if(i=='1')
{
digitalWrite(ledpin,1);
Serial.println("led on");
}
if(i=='0')
{
digitalWrite(ledpin,0);
Serial.println("led off");
}
if(i=='2')
{
digitalWrite(ledpin2,1);
Serial.println("led on");
}
if(i=='3')
{
digitalWrite(ledpin2,0);
Serial.println("led off");
}
if(i=='4')
{
digitalWrite(ledpin3,1);
Serial.println("led on");
}
if(i=='5')
{
digitalWrite(ledpin3,0);
Serial.println("led off");
}
}
}
Sadly I'm still learning how to draw up a schematic so I drew a picture that hopefully can kind of explain what's going on if not I will try and draft up a schematic though.
Also new account so I can't post multiple links so sorry for the clutter but ill post each hardware link separately.
Mosfets
Arduino
Bluetooth Module
Which one is the second one?
pin 12 is not dimmable
#include <SoftwareSerial.h>
//SoftwareSerial mySerial(2,3);
int ledpin = 11;
int ledpin2 = 12;
int ledpin3 = 10;
void setup()
{
Serial.begin(9600);
pinMode(ledpin, OUTPUT);
}
void loop()
{
int i;
if (Serial.available())
{
i = Serial.read();
Serial.println("DATA RECEIVED:");
if (i == '1')
{
digitalWrite(ledpin, 1);
Serial.println("led on");
}
if (i == '0')
{
Serial.println("led off");
for (int i = 255; i >= 0; i--) {
analogWrite(ledpin, i);
delay(5);
}
}
if (i == '2')
{
digitalWrite(ledpin2, 1);
Serial.println("led on");
}
if (i == '3')
{
digitalWrite(ledpin2, 0);
Serial.println("led off");
}
if (i == '4')
{
digitalWrite(ledpin3, 1);
Serial.println("led on");
}
if (i == '5')
{
digitalWrite(ledpin3, 0);
Serial.println("led off");
}
}
}
You need a pinMode for all of your LED pins
Thanks so much for now that seems to have been the solution I added PinMode for all three and now their each working separately. Thanks so much for everyone's help I'll let you know if anything else comes up. Thanks again.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.