Show Posts
Pages: [1] 2 3 4
1  Using Arduino / General Electronics / Re: Does a mosfet require PWM? on: July 19, 2014, 01:43:26 am
Since wikitjuggla is a beginner (sorry wikitjuggla), and it is about a led strip.
Using a pot meter would be very hard and the mosfet could get too hot without heatsink. So yes, in this situation is pwm needed, and a pot meter would even be wrong  smiley-roll-sweat

A mosfet can be used in an analog circuit, like in a radio transmitter amplifier.  smiley-surprise

I can't remember for sure but a while back i'm pretty sure I ran a light strip at 2.0 amps off of the same mosfet with only a POT for about 10 minutes. It got hot enough to where you couldn't keep your finger on it for more than 5 or so seconds but that was without a heat sink. Now I only require 0.5 amps and have a heatsink
2  Using Arduino / General Electronics / Re: Does a mosfet require PWM? on: July 19, 2014, 01:37:20 am
With the dual element light bulbs, the brake light filaments of both bulbs are wired independent of each other in order for the blinkers to work but the second tail light elements are wired parallel so if I connect the mosfet, it will wire the two LED strips in parallel to each other and the blinker circuit in parallel with the tail light circuit also, causing my entire blinker system to be wired in parallel and not work so i need the diodes in order to keep the two circuits independent of each other and to keep both blinkers independent of each other
3  Using Arduino / General Electronics / Re: Does a mosfet require PWM? on: July 19, 2014, 12:44:41 am
Well I have an irf520n mosfet running a 0.5 amp load. I have heat sinks and an arduino but it seems like an overly simple task for an arduino. What would you recommend?

Also I have the strip cut in half and one half wired to each tail light but I know wiring in the mosfet will connect the two halves in parallel so I need to use a couple diodes. Would a 1n4007 diode running at 0.25 amps per half suffice? I'm not very good at understanding the data sheets
4  Using Arduino / General Electronics / Does a mosfet require PWM? on: July 19, 2014, 12:19:22 am
I want to use a mosfet to dim an LED light strip at 0.5 amps. Do I need to use an arduino and PWM or can I just connect a POT across the mosfet gate? I'm using a 12v light strip as a brake light and wish to have it illuminated when just the tail lights are on like a Dual element tail light bulb

Thank You
5  Using Arduino / Programming Questions / Re: Simple Headlight Control Code on: December 19, 2013, 12:30:16 am
Code:
#define SENSOR 0  // select the input pin for the
                  // sensor resistor

int val = 0; // variable to store the value coming
             // from the sensor
const int relay = 12;
const int ignition = 11;

void setup() {
 


 Serial.begin(9600); // open the serial port to send
                     // data back to the computer at
pinMode(relay, OUTPUT);                 // 9600 bits per second
pinMode(ignition, INPUT);
}

void loop() {
 
 
 
 { val = analogRead(SENSOR); // read the value from
                            // the sensor

  Serial.println(val); // print the value to
                       // the serial port

  delay(100); // wait 100ms between
              // each send 
 }
 
 if (digitalRead (ignition) == HIGH) {
 
   if (analogRead(SENSOR) <500) {
     digitalWrite(relay, LOW);
     delay(120000);         //delay sensor readings to prevent headlight
   } else {                 //shut off at night from street lights, other cars..ect
     digitalWrite(relay, HIGH);
   }
 } else {
  delay(120000); //keep lights on 2 minutes after ignition off
  digitalWrite(relay, LOW);
  }
}
 
 

Does that "delay(100)" after "serial.println" also need to be changed to millis() or is that a small enough of a delay that it won't make a difference?
6  Using Arduino / Programming Questions / Re: Simple Headlight Control Code on: December 18, 2013, 11:57:03 pm
Before moving on you need to fix the original code
Code:
 if (digitalRead (ignition), HIGH)
This will probably work but it is wrong.

Once this is fixed change the program to use millis() for timing.  The BlinkWithoutDelay example in the IDE and http://gammon.com.au/blink will get you started nut feel free to ask for help here.  Once the main program works using millis() you can set about integrating the second one which will be easy once loop() is free running and not blocked by delays.

Well that gammon link is a lot easier for me to interpret than the blinkwithoutdelay example on the arduino website but, I still haven't a clue on how to implement that into my sketch or how to make it conditional to only happen and keep the lights on for 2 minutes after I turn off the ignition key. I spent a long time looking at it and I get the idea easily enough but just don't know how to implement it for anything else but...well, blinking an led
7  Using Arduino / Programming Questions / Re: Simple Headlight Control Code on: December 18, 2013, 02:08:05 pm
and do all sketches using millis() use that "if(currentMillis - previousMillis > interval)"
8  Using Arduino / Programming Questions / Re: Simple Headlight Control Code on: December 18, 2013, 02:06:04 pm
So should I replace all my sketches using only "int" with "const int" for a more reliable sketch
9  Using Arduino / Programming Questions / Re: Simple Headlight Control Code on: December 18, 2013, 04:25:34 am
Do I need one = or the ==? whats the difference between "const int" and just using "int" its kind of ridiculous that there are about a 100 different ways of accomplishing the same end result with arduino. Makes it very hard to learn
10  Using Arduino / Programming Questions / Re: Simple Headlight Control Code on: December 18, 2013, 03:35:40 am
Alright so i believe this to be the code I need to control my mosfets. I am totally lost at integrating this code and the one from above together. I was somewhat of a noob but i haven't touched my arduino in months so i'm pretty much right back at square one. The codes I have come up with thus far are bits and pieces of code I put together from codes I implemented months ago in different projects

Code:

int sensorPin = A1;   
int mosfet = 9;     
int val = 0; 

void setup() {
  pinMode(mosfet, OUTPUT); 
}

void loop() {
 
  val = analogRead(sensorPin);
val = map(val,0, 1023, 0, 255);
 
  analogWrite(mosfet, val); 
       
}
11  Using Arduino / Programming Questions / Re: Simple Headlight Control Code on: December 18, 2013, 02:44:06 am
well I know when I had my motion sensor lamp going, If you set off the motion sensor again, say a minute after setting it off the first time, it would start/reset the 2 minute cycle all over again before the first one ended . Idk, maybe that was a loop hole in my favor in the code i wrote. I've never used millis() before. Not quite sure how it works. I plan on also using an arduino as a PWM Controller with a POT for mosfets controlling something else entirely in the same vehicle. Would I be able to have the same arduino accomplish both tasks simultaneously?
12  Using Arduino / Programming Questions / Re: Simple Headlight Control Code on: December 18, 2013, 02:18:09 am
I've used a 120000 millisecond delay before w/o issue on my uno rev 3 with a motion sensor lamp I made. Other than that how does the code look? I should probably put that first IF statement after the serial monitor command though I suppose?
13  Using Arduino / Programming Questions / Re: Simple Headlight Control Code on: December 18, 2013, 02:04:18 am
sorry haha, the website was taking forever to upload my thread so I had to reset the page and i guess it posted it twice
14  Using Arduino / Programming Questions / Simple Headlight Control Code on: December 18, 2013, 01:46:22 am
I'm thinking about making my car headlights turn on/off automatically for day/night with an additional 2 minute delay after I turn off the car.  The code I made up seems pretty solid but would like someone else to look at it to be safe. I might have my sensor values and relay low/high values mixed around but i'm not worried about that till i bench test it. Just want to know if the code will work

Code:
// Example 07: Send to the computer the values read from
// analogue input 0
// Make sure you click on "Serial Monitor"
// after you upload
//
// Copy and paste this example into an empty Arduino sketch

#define SENSOR 0  // select the input pin for the
                  // sensor resistor

int val = 0; // variable to store the value coming
             // from the sensor
int relay = 12;
int ignition = 11;

void setup() {
 


 Serial.begin(9600); // open the serial port to send
                     // data back to the computer at
pinMode(relay, OUTPUT);                 // 9600 bits per second
pinMode(ignition, INPUT);
}

void loop() {
 
  if (digitalRead (ignition), HIGH) {
 
 { val = analogRead(SENSOR); // read the value from
                            // the sensor

  Serial.println(val); // print the value to
                       // the serial port

  delay(100); // wait 100ms between
              // each send 
 }
 
   if (analogRead(SENSOR) <500) {
     digitalWrite(relay, LOW);
     delay(120000);         //delay sensor readings to prevent headlight
   } else {                 //shut off at night from street lights, other cars..ect
     digitalWrite(relay, HIGH);
   }
  } else {
  delay(120000); //keep lights on 2 minutes after ignition off
  digitalWrite(relay, LOW);
  }
}
 
 
15  Using Arduino / General Electronics / Re: Using Mosfet For PWM In HHO Generator on: December 17, 2013, 01:55:18 am
I found a better mosfet http://www.ebay.com/itm/331085945741?ssPageName=STRK:MEWAX:IT&_trksid=p3984.m1423.l2649 uses a 3-5 volt gate drive and someone else has successfully used 3 of them with an arduino at 20 amps with little to no heat using a 45mm heat sink and a same sized fan. Now is just the question of controlling the frequency
Pages: [1] 2 3 4