Show Posts
Pages: 1 ... 5 6 [7] 8
91  Using Arduino / Programming Questions / Re: Using Serial.Print in caller function? Is this even possible? on: July 10, 2012, 09:32:31 pm
You will certainly get an error with
92  Using Arduino / Programming Questions / Re: Arduino & Processing Serial Communcation Problem on: July 10, 2012, 09:16:52 pm
Get rid of that Serial.list()[0] line (who started that nonsense, anyway?).  Replace portName with "COM3" or whatever port your Arduino uses.  This works on my computer:

  // the name of port connecting the arduino
  myPort = new Serial(this, "COM6", 9600);
93  Using Arduino / General Electronics / Re: How do voltage regulators fail? on: July 09, 2012, 10:14:06 pm
I had a LM317 adjustable voltage regulator fail recently.  The output was set at 7.5 volts, but after a few hours it failed gracefully by going to zero.  The problem must have been heat (4 Watts?).  The supply was 24 volts dc, and the draw was 250 mA. 
94  Using Arduino / Project Guidance / Re: Monitoring PWM- best way for newbie? on: July 08, 2012, 12:29:52 am
Hm...not being an electronics expert, I assumed there was an easy way to get average voltage through some kind of component or filter.  If not, you could try averaging it like this:

// measure PWM voltage (duty cycle between 0.0 and 1.0)
// connect a jumper from digital pin 3 to analog pin 2
// start serial monitor to see average voltage

float average, alpha=.99, newValue, oldValue=0.0, duty=.8;     

void setup() {
  pinMode(3, OUTPUT);

void loop() {
  analogWrite(3, 255*duty);
  newValue = analogRead(2);
  average = oldValue*alpha + (1-alpha)*newValue;
  oldValue = average;

Play around with this - all you need is one wire. Try it for different duty cycles. The closer to 1.0 you make alpha, the better the average but the slower the response time. This shouldn't be a problem since you are only concerned with steady-state data.
95  Using Arduino / Project Guidance / Re: Monitoring PWM- best way for newbie? on: July 07, 2012, 04:44:47 pm
Not sure this will help, but isn't "reading" a PWM signal the same as measuring the average voltage?  If so, just read the PWM voltage.  For a square wave, measuring the area under the curve is trivial.  It's just average voltage * time.

If I understand your question correctly, you could measure the voltage at regular intervals and multiply by the interval (in seconds) to get a number proportional to the fuel consumed during the interval.  Frequency of the PWM does not matter because you're reading the average.
96  Using Arduino / Programming Questions / Re: Small DC motor doesnt like my code on: July 05, 2012, 11:00:51 am
What is the motor doing (or not doing) that you don't want? 

analogWrite(motorpwm, 50);
  This is less than 1 volt.  Does the motor run OK on less than 1 volt?
97  Development / Suggestions for the Arduino Project / Re: Clearing the Serial Monitor screen on: July 05, 2012, 10:45:08 am
For example, if I want a temperature reading, I don't need a million lines of text printing every 0.1 seconds, but a single line of text that changes. Who else agrees?

Good suggestion.  I agree this would be a nice feature. 
98  Using Arduino / Programming Questions / Re: question about the makeKeymap function in the keypad.h library on: July 05, 2012, 08:53:40 am
Is it possible to define the array as a 2d array of integers??

Sure, here is a sketch I wrote yesterday to light a seven segment LED with a 4x3 keypad.  (edit) It may be easier to do what you want if you code it directly without using a library. (edit)

// 7 segment LED display LSD3211-11 and 3X4 keypad
// pin 13 to segment a of display, 14 to b, 15 to c, etc.
// keypad plugged into Arduino using pins 0-6

int key, i, j, k;
//               a b c d e f g
int seg[][7] = {{1,1,1,1,1,1,0},  // 0
                {0,1,1,0,0,0,0},  // 1
                {1,1,0,1,1,0,1},  // 2
                {1,1,1,1,0,0,1},  // 3
                {0,1,1,0,0,1,1},  // 4
                {1,0,1,1,0,1,1},  // 5
                {1,0,1,1,1,1,1},  // 6
                {1,1,1,0,0,0,0},  // 7
                {1,1,1,1,1,1,1},  // 8
                {1,1,1,1,0,1,1},  // 9
                {1,1,0,1,0,1,1},  // *, 10
                {0,1,1,0,1,1,0}}; // #, 11

int pad[][7] = {{-1, 2,-1, 0,-1, 8, 5},  // keypad
                {-1,-1, 1,-1, 3,-1,-1},
                {-1,-1,-1,10,-1, 7, 4},
                {-1,-1,-1,-1,-1, 9, 6}};
void setup() {
  for(i=13; i<20; i++)    // display uses digital pins 13-19
    pinMode(i, OUTPUT);

void loop() {
  for(j=0; j<5; j++) {                     // get one keypress
    pinMode(j, OUTPUT);                  
    digitalWrite(j, LOW);                  // set one pin LOW
    for(i=j+1; i<7; i++) {                 // check other pins
      pinMode(i, INPUT_PULLUP);            // which are HIGH
      if(digitalRead(i)==LOW) {            // if one found LOW
        key = pad[j][i];                   // save i, j values
        for(k=0; k<7; k++) {              
          digitalWrite(13+k, seg[key][k]); // show the keypress
    digitalWrite(j, HIGH);                 // set back to HIGH

The pad[][] array contains integers so I could use them to directly index the seg[][] array.  The -1's are just placeholders because some pin combinations don't do anything.  
99  Using Arduino / Installation & Troubleshooting / Re: When you burn out one pin... on: July 03, 2012, 11:55:29 am
You shouldn't be, I have never seen anyone put down for asking a "dum" question. In my book there is no such thing, if you don't know then you don't know.

Thanks for the encouragement.  I think my perception of "put down" is probably different than yours.  The main thing was I didn't want someone to point out something that I could have worked out for myself.  So far I've been able to answer my own questions by looking it up on this forum (thank you all!) or performing some kind of test with the components or software.   
100  Using Arduino / Installation & Troubleshooting / Re: When you burn out one pin... on: July 02, 2012, 10:10:41 pm
Next time, turn the power off before rewiring. It can prevent the smoke from coming out  smiley-grin

Good advice.  Maybe I'll do that when I have only a few good pins remaining  smiley-twist

I have learned a lot and in this Computer Science you learn a lot and you continue always its never ending ,You are learning even on the day you Die, its so much Deep.

You are right, I have learned a ton since I bought an Arduino 2 months ago.  Much of what I learned was from YouTube and this forum.  The rest was from figuring it out on my own because I was afraid to ask a question on the forum!
101  Using Arduino / Installation & Troubleshooting / Re: When you burn out one pin... on: July 02, 2012, 10:32:33 am
No, I didn't, but thanks for asking.  Sorry I misunderstood the question.  The pump motor I'm using has a control board with it, so I only need to supply a 0-5 volt signal to the control board in order to run the motor from zero to full speed.  In fact, being new to this sort of thing, I made sure the motor I bought came with a control board! 
102  Using Arduino / Installation & Troubleshooting / Re: When you burn out one pin... on: July 02, 2012, 10:16:42 am
How was the motor connected to the pins?

The motor was connected to the board with 22 gauge jumpers.  Actually, it wasn't properly connected at the time of the accident.  I think I was trying to rewire something on my breadboard when the 24 VDC supply wire came loose and I was probably waving it around while trying to re-connect it.  The actual damage happeded suddenly - literally in a flash!
103  Using Arduino / Installation & Troubleshooting / Re: When you burn out one pin... on: July 02, 2012, 10:10:22 am
I'd replace the chip. No telling what collateral damage may have occurred that could cause future failures.

Sounds like good advice, but the chip on this Osep clone board is surface mount.  Replacing it would be too difficult for me.  Good news is the other pins seem to be fine so far.

104  Using Arduino / Installation & Troubleshooting / Re: When you burn out one pin... on: July 02, 2012, 02:43:32 am
The moral is to not burn pins out?  I hope that was a joke.  We all make mistakes and hopefully learn from them.
105  Using Arduino / Sensors / Re: accelerometer angle reading on: July 02, 2012, 02:33:58 am
If one axis is parallel to the motor shaft and it reads full gravity (1 g) at zero degrees, it will read .707 g when tilted at 45 degrees.  As long as you start with the accelerometer reading full gravity at zero degrees, the general formula for any other angle is:
value = g* cos(angle), where g = earth gravity and angle is in radians.  (1 degree = 0.01745 radians).

By the way, have you actually tried to do any of this?  If so, what have you done?  Have you looked into using servos?

Pages: 1 ... 5 6 [7] 8