Show Posts
Pages: [1] 2
1  Using Arduino / Programming Questions / Re: Driving Multiplexed 7 Segment Display with Shift Register on: March 03, 2013, 11:34:42 pm
Thank you very much. I will take a look at the code and see if I can have an AHA moment.  smiley
2  Using Arduino / Programming Questions / Re: Driving Multiplexed 7 Segment Display with Shift Register on: March 03, 2013, 10:18:39 pm
Disregard the last post. I accidentally switched the Shift Clock and Storage Clock in the program.
3  Using Arduino / Programming Questions / Re: Driving Multiplexed 7 Segment Display with Shift Register on: March 03, 2013, 09:59:04 pm
I redid my code so I've done away with the huge number bytes and rearranged them into one byte, but no matter what number I try to run it just lights up all of the LEDs. Any ideas what could be going wrong? I have run my original countdown from nine code and it works, so nothing is wrong with the wiring or anything physical... its here somewhere.

Code:
boolean data = 2;
boolean clock = 3;
boolean latch = 4;
boolean cathodeOne = 9;
boolean cathodeTwo = 10;
boolean cathodeThree = 11;
boolean cathodeFour = 12;

void clockTick()
{
  digitalWrite(clock, HIGH);
  digitalWrite(clock, LOW);
}

void latchTick()
{
 digitalWrite(latch, HIGH);
digitalWrite(latch, LOW);
}

byte numbers[11][8]={
  {0,0,1,1,1,1,1,1}, //zero
  {0,0,0,0,0,1,1,0}, //one
  {0,1,0,1,1,0,1,1}, //two
  {0,1,0,0,1,1,1,1}, //three
  {0,1,1,0,0,1,1,0}, //four
  {0,1,1,0,1,1,0,1}, //five
  {0,1,1,1,1,0,0,1}, //six
  {0,0,0,0,0,1,1,1}, //seven
  {0,1,1,1,1,1,1,1}, //eight
  {0,1,1,0,1,1,1,1}, //nine
  {0,0,0,0,0,0,0,0}, //off
};

/*byte Zero[1][8]={0,0,1,1,1,1,1,1};
byte One[1][8]={0,0,0,0,0,1,1,0};
byte Two[1][8]={0,1,0,1,1,0,1,1};
byte Three[1][8]={0,1,0,0,1,1,1,1};
byte Four[1][8]={0,1,1,0,0,1,1,0};
byte Five[1][8]={0,1,1,0,1,1,0,1};
byte Six[1][8]={0,1,1,1,1,0,0,1};
byte Seven[1][8]={0,0,0,0,0,1,1,1};
byte Eight[1][8]={0,1,1,1,1,1,1,1};
byte Nine[1][8]={0,1,1,0,1,1,1,1};*/

void zero()
{
  for(int x=0; x<8; x++)
  {
  digitalWrite(data, numbers[0][x]);
  clockTick();
  }
  latchTick();
  delay(2);
}

void one()
{
  for(int x=0; x<8; x++)
  {
  digitalWrite(data, numbers[1][x]);
  clockTick();
  }
  latchTick();
}

void two()
{
  for(int x=0; x<8; x++)
  {
  digitalWrite(data, numbers[2][x]);
  clockTick();
  delay(5);
  }
  latchTick();
}

void three()
{
  for(int x=0; x<8; x++)
  {
  digitalWrite(data, numbers[3][x]);
  clockTick();
  }
  latchTick();
}

void four()
{
  for(int x=0; x<8; x++)
  {
  digitalWrite(data, numbers[4][x]);
  clockTick();
  }
  latchTick();
}

void five()
{
  for(int x=0; x<8; x++)
  {
  digitalWrite(data, numbers[5][x]);
  clockTick();
  }
  latchTick();
}

void six()
{
  for(int x=0; x<8; x++)
  {
  digitalWrite(data, numbers[6][x]);
  clockTick();
  }
  latchTick();
}

void seven()
{
  for(int x=0; x<8; x++)
  {
  digitalWrite(data, numbers[7][x]);
  clockTick();
  }
  latchTick();
}

void eight()
{
  for(int x=0; x<8; x++)
  {
  digitalWrite(data, numbers[8][x]);
  clockTick();
  }
  latchTick();
}

void nine()
{
  for(int x=0; x<8; x++)
  {
  digitalWrite(data, numbers[9][x]);
  clockTick();
  }
  latchTick();
}

void off()
{
   for(int x = 0; x < 8; x++)
  {
  digitalWrite(data, numbers[10][x]);
  clockTick();
  }
  latchTick();
}

void setup()
{
  pinMode(clock, OUTPUT);
  pinMode(data, OUTPUT);
  pinMode(latch, OUTPUT);
  pinMode(cathodeOne, OUTPUT);
  pinMode(cathodeTwo, OUTPUT);
  pinMode(cathodeThree, OUTPUT);
  pinMode(cathodeFour, OUTPUT);
  digitalWrite(cathodeOne, HIGH);
}

void loop()
{
 
zero();
delay(5);

}
4  Using Arduino / Programming Questions / Re: Driving Multiplexed 7 Segment Display with Shift Register on: March 03, 2013, 08:47:12 pm
I used the SN74HC595 because I wanted to try my hand at using a shift register instead of just using 8 I/O pins.

I wanted to try and make each segment of the number light up one at a time so that the change in brightness say from a "1" to an "8" would be as nominal as possible.

At this point I'm assuming it would be more reasonable (assuming I keep using the shift register) to set each number up as an array with every segment lit at the same time and just flash entire digits at once?

I am pretty new to electronics in general. I have looked at several tutorials and whatnot but never picked up enough from them to really know what I was doing, so I set out to learn by doing.

What would you suggest as far as simplification?
5  Using Arduino / Programming Questions / Re: Driving Multiplexed 7 Segment Display with Shift Register on: March 03, 2013, 06:04:08 pm
Here is my code. The original post was too long with it.

Code:
boolean data = 2;
boolean latch = 3;
boolean clock = 4;
boolean cathodeOne = 9;
boolean cathodeTwo = 10;
boolean cathodeThree = 11;
boolean cathodeFour = 12;
unsigned long timer;
unsigned long previousMillis = 0;
byte Zero[6][8] = {
  {
    0,0,1,0,0,0,0,0  }
  ,
  {
    0,0,0,1,0,0,0,0  }
  ,
  {
    0,0,0,0,1,0,0,0  }
  ,
  {
    0,0,0,0,0,1,0,0  }
  ,
  {
    0,0,0,0,0,0,1,0  }
  ,
  {
    0,0,0,0,0,0,0,1  }
  ,
};
byte One[2][8] = {
  {
    0,0,0,0,0,1,0,0  }
  ,
  {
    0,0,0,0,0,0,1,0  }
};

byte Two[5][8] = {
  {
    0,1,0,0,0,0,0,0  }
  ,
  {
    0,0,0,1,0,0,0,0  }
  ,
  {
    0,0,0,0,1,0,0,0  }
  ,
  {
    0,0,0,0,0,0,1,0  }
  ,
  {
    0,0,0,0,0,0,0,1  }
};

byte Three[5][8] = {
  {
    0,1,0,0,0,0,0,0  }
  ,
  {
    0,0,0,0,0,1,0,0  }
  ,
  {
    0,0,0,0,1,0,0,0  }
  ,
  {
    0,0,0,0,0,0,1,0  }
  ,
  {
    0,0,0,0,0,0,0,1  }
  ,
};

byte Four[4][8] = {
  {
    0,1,0,0,0,0,0,0  }
  ,
  {
    0,0,1,0,0,0,0,0  }
  ,
  {
    0,0,0,0,0,1,0,0  }
  ,
  {
    0,0,0,0,0,0,1,0  }
  ,
};

byte Five[5][8] = {
  {
    0,1,0,0,0,0,0,0  }
  ,
  {
    0,0,0,0,0,1,0,0  }
  ,
  {
    0,0,0,0,1,0,0,0  }
  ,
  {
    0,0,1,0,0,0,0,0  }
  ,
  {
    0,0,0,0,0,0,0,1  }
};

byte Six[6][8] = {
  {
    0,0,1,0,0,0,0,0  }
  ,
  {
    0,0,0,1,0,0,0,0  }
  ,
  {
    0,0,0,0,1,0,0,0  }
  ,
  {
    0,0,0,0,0,1,0,0  }
  ,
  {
    0,1,0,0,0,0,0,0  }
  ,
  {
    0,0,0,0,0,0,0,1  }
  ,
};

byte Seven[3][8] = {
  {
    0,0,0,0,0,1,0,0  }
  ,
  {
    0,0,0,0,0,0,1,0  }
  ,
  {
    0,0,0,0,0,0,0,1  }
  ,
};

byte Eight[7][8] = {
  {
    0,1,0,0,0,0,0,0  }
  ,
  {
    0,0,1,0,0,0,0,0  }
  ,
  {
    0,0,0,1,0,0,0,0  }
  ,
  {
    0,0,0,0,1,0,0,0  }
  ,
  {
    0,0,0,0,0,1,0,0  }
  ,
  {
    0,0,0,0,0,0,1,0  }
  ,
  {
    0,0,0,0,0,0,0,1  }
  ,
};

byte Nine[6][8] = {
  {
    0,1,0,0,0,0,0,0  }
  ,
  {
    0,0,1,0,0,0,0,0  }
  ,
  {
    0,0,0,0,1,0,0,0  }
  ,
  {
    0,0,0,0,0,1,0,0  }
  ,
  {
    0,0,0,0,0,0,1,0  }
  ,
  {
    0,0,0,0,0,0,0,1  }
  ,
};

void clockTick()
{
  digitalWrite(clock, HIGH);
  digitalWrite(clock, LOW);
}

void latchTick()
{
  digitalWrite(latch, HIGH);
  digitalWrite(latch, LOW);
}

void zero()
{
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Zero[0][x]);
    clockTick();
  }
  latchTick();
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Zero[1][x]);
    clockTick();
  }
  latchTick();
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Zero[2][x]);
    clockTick();
  }
  latchTick();
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Zero[3][x]);
    clockTick();
  }
  latchTick();
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Zero[4][x]);
    clockTick();
  }
  latchTick();
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Zero[5][x]);
    clockTick();
  }
  latchTick();
}

void one()
{
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, One[0][x]);
    clockTick();
  }
  latchTick();
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, One[1][x]);
    clockTick();
  }
  latchTick();
}

void two()
{
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Two[0][x]);
    clockTick();
  }
  latchTick();
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Two[1][x]);
    clockTick();
  }
  latchTick();
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Two[2][x]);
    clockTick();
  }
  latchTick();
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Two[3][x]);
    clockTick();
  }
  latchTick();
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Two[4][x]);
    clockTick();
  }
  latchTick();
}

void three()
{
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Three[0][x]);
    clockTick();
  }
  latchTick();
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Three[1][x]);
    clockTick();
  }
  latchTick();
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Three[2][x]);
    clockTick();
  }
  latchTick();
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Three[3][x]);
    clockTick();
  }
  latchTick();
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Three[4][x]);
    clockTick();
  }
  latchTick();
}

void four()
{
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Four[0][x]);
    clockTick();
  }
  latchTick();
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Four[1][x]);
    clockTick();
  }
  latchTick();
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Four[2][x]);
    clockTick();
  }
  latchTick();
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Four[3][x]);
    clockTick();
  }
  latchTick();
}

void five()
{
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Five[0][x]);
    clockTick();
  }
  latchTick();
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Five[1][x]);
    clockTick();
  }
  latchTick();
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Five[2][x]);
    clockTick();
  }
  latchTick();
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Five[3][x]);
    clockTick();
  }
  latchTick();
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Five[4][x]);
    clockTick();
  }
  latchTick();
}

void six()
{
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Six[0][x]);
    clockTick();
  }
  latchTick();
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Six[1][x]);
    clockTick();
  }
  latchTick();
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Six[2][x]);
    clockTick();
  }
  latchTick();
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Six[3][x]);
    clockTick();
  }
  latchTick();
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Six[4][x]);
    clockTick();
  }
  latchTick();
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Six[5][x]);
    clockTick();
  }
  latchTick();
}

void seven()
{
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Seven[0][x]);
    clockTick();
  }
  latchTick();
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Seven[1][x]);
    clockTick();
  }
  latchTick();
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Seven[2][x]);
    clockTick();
  }
  latchTick();
}

void eight()
{
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Eight[0][x]);
    clockTick();
  }
  latchTick();
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Eight[1][x]);
    clockTick();
  }
  latchTick();
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Eight[2][x]);
    clockTick();
  }
  latchTick();
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Eight[3][x]);
    clockTick();
  }
  latchTick();
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Eight[4][x]);
    clockTick();
  }
  latchTick();
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Eight[5][x]);
    clockTick();
  }
  latchTick();
  latchTick();
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Eight[6][x]);
    clockTick();
  }
  latchTick();
}

void nine()
{
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Nine[0][x]);
    clockTick();
  }
  latchTick();
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Nine[1][x]);
    clockTick();
  }
  latchTick();
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Nine[2][x]);
    clockTick();
  }
  latchTick();
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Nine[3][x]);
    clockTick();
  }
  latchTick();
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Nine[4][x]);
    clockTick();
  }
  latchTick();
  for (int x = 0; x < 8; x++)
  {
    digitalWrite(data, Nine[5][x]);
    clockTick();
  }
  latchTick();
}

void setup()
{
  pinMode(data, OUTPUT);
  pinMode(latch, OUTPUT);
  pinMode(clock, OUTPUT);
  pinMode(cathodeOne, OUTPUT);
  pinMode(cathodeTwo, OUTPUT);
  pinMode(cathodeThree, OUTPUT);
  pinMode(cathodeFour, OUTPUT);

}

void loop()
{
  timer = millis();
  digitalWrite(cathodeOne, HIGH);

  if(timer - previousMillis < 1000)
    nine();
  else if(timer - previousMillis >= 1000 && timer - previousMillis < 2000)
    eight();
  else if(timer - previousMillis >= 2000 && timer - previousMillis <3000)
    seven();
  else if(timer - previousMillis >= 3000 && timer - previousMillis <4000)
    six();
  else if(timer - previousMillis >= 4000 && timer - previousMillis <5000)
    five();
  else if(timer - previousMillis >= 5000 && timer - previousMillis <6000)
    four();
  else if(timer - previousMillis >= 6000 && timer - previousMillis <7000)
    three();
  else if(timer - previousMillis >= 7000 && timer - previousMillis <8000)
    two();
  else if(timer - previousMillis >= 8000 && timer - previousMillis <9000)
    one();
  else zero();
}
6  Using Arduino / Programming Questions / Driving Multiplexed 7 Segment Display with Shift Register on: March 03, 2013, 06:03:52 pm
I am trying to drive a 4 character, common cathode (4),  7 segment display (datasheet here: http://www.jameco.com/Jameco/Products/ProdDS/335194.pdf) with an SN74HC595N shift register (datasheet here: http://www.ti.com/lit/ds/symlink/sn74hc595.pdf). I want to make a countdown timer, and I have successfully created all the numbers using bytes so that only one segment is lit at a time per number with no delay() use. I am controlling each cathode with a PN2222A NPN transistor (datasheet here: http://www.fairchildsemi.com/ds/PN/PN2222A.pdf) to turn them on or off.  

Pictures:
http://www.flickr.com/photos/brandondub/8526389172/in/photostream
http://www.flickr.com/photos/brandondub/



At this point, I would like to expand its functionality beyond the single digit I have working now to being able to use at least 3 digits so that I can have a countdown timer capable of times upwards of a minute.

What I am wondering is if there is a way to make the time easily changeable and automate when digits turn on and off as a function of the "time" remaining on the clock. So for example, make it to where I can change a variable to 100 and the clock would start at 1.40 (100 seconds) and then count down. I am not sure how to automate the cathode enabling in respect to time remaining or how to program the clock to countdown from minutes to seconds (2.00 - 1.59) or even from  0.10 - 0.09.

Does anyone have experience with this? Thank you in advance for any advice you can give me.
7  Using Arduino / Programming Questions / Re: Homemade Arduino Library Modification on: January 31, 2013, 02:48:00 am
PROBLEM SOLVED!  smiley-lol


Header now reads:

Code:
#ifndef FlashingLED_h
#define FlashingLED_h

#include "Arduino.h"

class FlashingLED
{
public:
    FlashingLED(int pin);
    void flash(int on, int off);
private:
    int _pin;
    unsigned long timer;
};

#endif

Source Code:

Code:
#include "Arduino.h"
#include "FlashingLED.h"

FlashingLED::FlashingLED(int pin)
{
    pinMode(pin, OUTPUT);
    _pin = pin;
    unsigned long timer = millis();
}

void FlashingLED::flash(int on, int off)
{   
    if(millis() - timer < on)
        digitalWrite(_pin, HIGH);
    else if(millis() - timer >= on && millis() - timer < on + off)
    {
        digitalWrite(_pin, LOW);
    }
    else if(millis() - timer >= on + off)
        timer = millis();
}

And Arduino IDE:

Code:
/*   FlashingLEDExample
 
 Created by Brandon Whittle
 
 Made to emulate Blink and BlinkWithoutDelay examples with
 
 multiple LEDs with inequivalent on/off times.
 
 */

#include <FlashingLED.h>

FlashingLED myLED(13);
FlashingLED myLED2(12);

void setup()
{

}

void loop()
{
  myLED.flash(250, 250);
  myLED2.flash(1000, 1000);
}

Thank you for replying and sending me in the right direction!
8  Using Arduino / Programming Questions / Re: Homemade Arduino Library Modification on: January 31, 2013, 02:35:51 am
This is what I have (thrown together) as far as using ifs:

Code:
myLED.flash(200, 300);

//would equate to:

unsigned long timer = millis();

if(millis() - timer < on)
digitalWrite(_pin, HIGH);
else if(millis() - timer >= on && millis() - timer < on + off)
{
  digitalWrite(_pin, LOW);
  if(millis() - timer >= on + off)
    timer = millis();
}

But it isn't working... Hmmm...
9  Using Arduino / Programming Questions / Re: Homemade Arduino Library Modification on: January 31, 2013, 02:24:19 am
Balls... Hadn't thought about the while statement sucking the life out of this.

Your first call to millis()  makes no sense. 

For some reason I felt like I had to initialize millis() before I could use it. I'm not sure why... smiley-red

This would suggest that there should be some private long variable containing the last
flip time,  somewhere in your class.

Woud making the timer variable private in the header make it only usable by one pin even when others were blinking other LEDs?

Beyond this, is there any way to make this work with different times for on and off without using while statements? Can I get away with Ifs?
10  Using Arduino / Programming Questions / Re: Homemade Arduino Library Modification on: January 31, 2013, 02:16:04 am
Compare your code:

Code:
while (millis() - timer < on)
    {
    digitalWrite(_pin, HIGH);
    }
    timer = millis();
    while (millis() - timer < off)
    {
        digitalWrite(_pin, LOW);
    }

with blink without delay.

No "while" there... smiley

Hence the "more or less." I was referring to BlinkWithoutDelay in the way that they both use millis() and a variable to track the times, even though my execution was different because I am setting two parameters for the blink rather than one.
11  Using Arduino / Programming Questions / Homemade Arduino Library Modification on: January 31, 2013, 01:56:00 am
Tonight I decided I would try to make a very simple library for Arduino. I call it FlashingLED and it works with one function, flash(int on, int off), where on and off are microsecond values fed into a more or less BlinkWithoutDelay style millis() timer. It works fine for one LED, but when try to use it on more then one, the global variable "timer" is not unique to each LED so they screw with each other's timings and get all wonky.

Here is the header file:

Code:

#ifndef FlashingLED_h
#define FlashingLED_h

#include "Arduino.h"

class FlashingLED
{
public:
    FlashingLED(int pin);
    void flash(int on, int off);
private:
    int _pin;
};

#endif

And the source file:

Code:
#include "Arduino.h"
#include "FlashingLED.h"

FlashingLED::FlashingLED(int pin)
{
    pinMode(pin, OUTPUT);
    _pin = pin;
}

void FlashingLED::flash(int on, int off)
{
    millis();
    unsigned long timer = millis();
    while (millis() - timer < on)
    {
    digitalWrite(_pin, HIGH);
    }
    timer = millis();
    while (millis() - timer < off)
    {
        digitalWrite(_pin, LOW);
    }
    timer = millis();
   
}

As well as my example for one LED:

Code:
#include <FlashingLED.h>

FlashingLED myLED(13);

void setup()
{

}

void loop()
{
  myLED.flash(1000, 1000);
}

As far as "what have you tried," I have played with various values for the "on" and "off" values to see if it just looked odd because of my original times, and that wasn't the case. I then thought that maybe the pins were cross-talking due to "_pin = pin" in the source file, but decided that this wasn't necessarily the problem (but I have no real clue). I then decided that my problem was probably the fact that my source file code uses a global variable "timer" for all pins included.

Any ideas on how to restrict the timer variable to each pin?

Is there any way to give each pin its own timer based on something like timer(x) where x could just be a variable based on the pin number to keep the timers separate from pin to pin?

I would like to add that I am very new to coding and Arduino in general, I just like to learn by doing if possible. With that in mind, please don't start slinging techy programmer lingo at me (I assume this exists).
12  Using Arduino / General Electronics / Re: LEDs on: January 30, 2013, 12:42:47 pm
1) What lights a LED up? Voltage or current?

2) What does a resistor limit? Voltage or current? I mean, if I don't put a resistor in my circuit the LED bursts down: why? Too much volts or amperes?

This should get you started as far as answering questions 1 and 2: http://www.sparkfun.com/tutorials/219

3) What remains constant in a circuit? Voltage or current? I mean, what is the same at the start and at the end of a circuit? Volts or amperes?

It depends on your circuit. I asume that you are familiar with series and parallel circuits. In a series circuit, current is constant (assuming none of your resistors change values due to heat or other factors) and voltage will change from place to place. If you have a battery connected to two resistors (motors, resistors, anything really...) then you can use Ohm's Law to calculate everything about the circuit. Let's say we have a nine volt battery and two 50Ω resistors.

Ohm's Law: Voltage = Current x Resistance
We know Voltage (before the battery starts to die) is 9V. We also know the value of both of our resistors in the circuit. In series, resistors simply add their resistances to get a total. 50Ω + 50Ω = 100Ω, so now we have:

9V = I x 100Ω

To find current, divide each side by R:

9V/100Ω = (I(100Ω))/100Ω

0.09 = I

So the current is 0.09A, or 90mA. When working with many things currents will be listed in mA, so it's worth it to convert.

To find the voltage across a certain resistor you already know that the current (constant in series circuits) is 90mA, and you know the resistance of the part, here 50Ω. So:

V = 0.09A x 50Ω

V = 4.5V

The most important thing to get out of this is Ohm's Law. It is used everywhere and flipping it around, you can get almost whatever you want to know.

As far as parallel circuits go, you still use Ohm's law, but there are some important differences. Look here and see if you can get them figured out.

http://www.allaboutcircuits.com/vol_1/chpt_5/3.html

Here is another good source: http://www.electronics-tutorials.ws/dccircuits/dcp_2.html

4) How should I put resistors when I have more than one LED?

It will depend on your circuit. If all of the LEDs are coming on at once in series, you could get away with a single resistor calculated to supply the correct amount of current. (This is referred to as a current limiting resistor.)

If the lights are independent of each other then you will need a resistor for each LED.

5) How should I put resistors when I have series or parallel circuits?

Once you understand the various parts of series and parallel circuits, this will become easy for you to decide.

Hope that helps!

13  Using Arduino / General Electronics / Re: MOSFET Trouble on: January 30, 2013, 12:05:33 pm
On my board all of the ground buses are connected and I use separate buses for different voltages, so I'm (generally) automatically good on the grounds being connected. (I am powering other things directly from the Arduino so the ground is already present on the breadboard.)

This would be why I forgot to draw it in.
14  Using Arduino / General Electronics / Re: MOSFET Trouble on: January 29, 2013, 11:28:41 pm
Thank you so much! I'm off to hunt for a more appropriate transistor.  smiley-lol
15  Using Arduino / General Electronics / Re: MOSFET Trouble on: January 29, 2013, 10:20:24 pm
On my board all of the ground buses are connected and I use separate buses for different voltages, so I'm (generally) automatically good on the grounds being connected. (I am powering other things directly from the Arduino so the ground is already present on the breadboard.)

Would a TIP120 work with the 5V from the Arduino?

To be honest, I don't have the electromagnet in my hands because I have yet to make it. I am going to try and wind magnet wire around the core of an AC induction motor out of a microwave, which I should get tomorrow. I was playing with a "test" electromagnet today though, and off of a 9 volt it drew 1.2ish Amps. So...I'm hoping I can play with these numbers a little and say that 9V/1.2A = 7.5Ω in the system. Provided that is correct, 7.2V/7.5Ω = 0.96A. I also would like to believe that making the actual electromagnet will require more wire than the beefy nail I made today, so the resistance will be higher, and thus the current lower.

I realize that these numbers are pretty low... If you don't mind me bouncing another idea off of you: What if I wired 2-3 9 volts in parallel to give this a little extra current capacity, put some resistors in parallel with the electromagnet to reduce resistance, thus causing more of a draw on current? Do you think this would be viable for a short period of time? I really only need this to work for about 15 minutes tops.

Also, this just came to mind: Because an electromagnet builds up an inductive field, should I be putting a diode backwards across the inputs of the electromagnet to protect the transistor from the potential voltage spike when it is turned off?
Pages: [1] 2