Loading...
  Show Posts
Pages: 1 2 [3] 4 5 ... 8
31  Using Arduino / Project Guidance / Re: I would like to ask for advice on a project on: August 03, 2012, 11:05:49 pm
Sounds like a cool project!

You can do it, just take small steps.  Make a sketch for each part of the project.  Play with the ping sensor first, get it to print the distance in the serial monitor.  Make another sketch to move one of the motors.  Then make it move back and forth.  Then make a motor move using the ping sensor, and so on.
32  Using Arduino / Sensors / Re: What is the best way of X-axis motion sensing? on: August 03, 2012, 10:17:20 pm
Yes, I think it would work.  In fact, you should use 2 of them separated by a meter!

Wire them in series with one side at 5V and the other at ground.  Now if you read the analog value between the 2 sensors, you will be able to tell which direction each person was moving.  That's because blocking the light to one sensor will make the analog reading go up, and blocking the light to the other sensor will make the analog reading go down.
33  Using Arduino / Programming Questions / Re: Trying to program a speedometer on: August 03, 2012, 10:01:40 pm
I think your math is OK, but there are a several problems with the code:  floating inputs, division with ints, wrong variable type for micros(), etc.  

Try the sketch with my modifications below.  It stays in the first while loop until the first switch closes.  Then it stays in the second loop until the second switch closes.  Then it calculates the answer and prints it.  The delay is to prevent a lot of junk from printing. 1 second may be longer than necessary, but I assume your lap times are more than 1 second!

I used 2 wires connected to pins 9 and 10. A 3rd wire was connected to ground.  To simulate the 2 switches closing, I held the first 2 wires close together and dragged the ground wire over them so that each was grounded in rapid succession (first pin 9, then pin 10).  The numbers I got in the serial monitor were believeable mph values.  
Code:

const int startPin = 9;
const int stopPin = 10;
unsigned long startTime=0;
unsigned long stopTime=0;
float mph;

void setup () {
  Serial.begin(9600);
  pinMode(startPin, INPUT_PULLUP);
  pinMode(stopPin, INPUT_PULLUP);
}

void loop () {
  while(!startTime) {
    if(digitalRead(startPin) == LOW)
      startTime = micros();
  }
  while(!stopTime) {
    if(digitalRead(stopPin) == LOW)
      stopTime = micros();
  }
  mph = (3600000000/((stopTime - startTime)*5280));
  Serial.println(mph);
  startTime=0;
  stopTime=0;
  delay(1000);
}

(edit - added code tags!)
34  Community / Bar Sport / Re: C64=30 on: August 02, 2012, 01:30:47 pm
Quote
The C64 was the second computer I owned.

Vic 20?  Wait, the C64 was the THIRD computer I owned!
35  Using Arduino / Project Guidance / Re: Vat sitter on: August 01, 2012, 10:39:43 pm
Quote
Adding the exact amount of pulp and keeping the water to fiber ratio appropriate for a specific weight of paper is labor intensive and subjective at best.

I know you want a sensor, but...

The more pulp, the higher the specific gravity, right?  Suppose you had a float that would sink or rise depending on the density of the mix.  Something like a thin wooden rod about 10 inches long with a weight on one end.  You could mark it at the ideal level.
36  Community / Bar Sport / Re: C64=30 on: August 01, 2012, 10:27:25 pm
The C64 was the second computer I owned.  It had better sound, graphics, and was faster than the Atari.  I remember standing there in the store typing my prime number testing program into each machine...
37  Using Arduino / Programming Questions / Re: Arduino counter on: July 31, 2012, 10:17:51 pm
Code:
if (counter3 = 0){

Does that look right?  Not saying that's the whole problem, but it does need fixing. 

Also, when you get some time, have a look at arrays.  Arrays can make your sketch cleaner and easier to work with.
38  Using Arduino / Project Guidance / Re: Reading frequency on: July 31, 2012, 09:53:01 pm
Quote
I'll fool around with pulseIn tomorrow and see if i can get some results.

Hi plank,
Here's an easy way to play around with pulseIn().  The sketch measures the Arduino PWM frequency and the length of the HIGH and LOW pulses for each PWM value.  Try it out - you only need one wire!
Tom

Code:
// PWM analysis, Tom Fangrow, July 8, 2012
// connect a wire from digital pin 2 to digital pin 3

long hi, lo, x;
 
void setup() {
  pinMode(3, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  for(x=1; x<255; x++) {              // for all useful values
    analogWrite(3, x);                // output PWM on pin 3
    hi = pulseIn(2, HIGH);            // measure HIGH pulse
    lo = pulseIn(2, LOW);             // measure LOW pulse
    Serial.print("PWM: ");            // PWM value (1-254)
    Serial.print(x);                 
    Serial.print(", HI: ");           // signal at 5 volts
    Serial.print(hi);                 // for 'hi' microseconds
    Serial.print(", LO: ");           // signal at 0 volts
    Serial.print(lo);                 // for 'lo' microseconds
    Serial.print(", Freq: ");         // PWM frequency
    Serial.print(1000000/(hi + lo));
    Serial.println(" Hz");            // in pulses per second
  }
}
39  Community / Bar Sport / Re: Countdown to Level Up on: July 31, 2012, 11:59:16 am
The next ranking could be Shockley Member.  William Shockley was the 'other' inventor of the transistor.
40  Community / Bar Sport / Re: Countdown to Level Up on: July 30, 2012, 07:15:15 pm
Quote
I'll second that (so I can have an additional post!  smiley-mr-green)

Ha! good one.  Maybe there should be a special thread dedicated to getting additional posts? 

Wait, some threads seem to be like that already!  <wink>
41  Using Arduino / Sensors / Re: Measuring speed of a motorbike wheel on: July 30, 2012, 07:10:06 pm
Hi again Markosec,

You've made progress, but it still seems more complicated than it needs to be.  4 magnets? arrays? interrupts?  Maybe it would help if you saw an example of a simpler way.  One measurement per rotation.  See if you can work through the logic in loop() on the sketch below. The code is tested and works.  You can ignore the lines having to do with the lcd display if you want, and you will need to change the rollout to 1880 and convert from miles per hour to kilometers per hour.

Code:
// Written by Tom Fangrow, July 15, 2012
// reed switch on pin 4, LED on pin 13

#include <LiquidCrystal.h>

LiquidCrystal lcd(3, 5, 9, 10, 11, 12);
unsigned long newTime, oldTime=0;
float newPeriod, oldPeriod=0.0, velocity;
float rollout = 2085.0;      // tire circumference in mm

void setup() {
  pinMode(4, INPUT_PULLUP);  // other side of switch to ground
  pinMode(13, OUTPUT);
  lcd.begin(16, 2);
  lcd.setCursor(0, 0);
  lcd.print("Bike Computer");              // welcome screen
  lcd.setCursor(0, 1);
  lcd.print("version 1.0");
  delay(3000);
}

void loop() {
  if(digitalRead(4) == LOW) {              // switch is closed
    newTime = millis();                    // note the time
    digitalWrite(13, HIGH);                // turn on LED
    newPeriod = float(newTime-oldTime);    // rotation period
    velocity = rollout*60*60/(newPeriod*1609.34);     // mph
    updateScreen();
    oldTime = newTime;                     // update oldTime
    oldPeriod = newPeriod;                 // update oldPeriod
    delay(60);           // allow time for switch to open again
  }
  else {                                   // switch is open
    digitalWrite(13, LOW);                 // turn off LED
    if(millis()-oldTime > 3000) {          // if bike stopped
      velocity = 0.0;                      // zero out display
      updateScreen();
      oldTime = millis();    // this will refresh every 3 seconds
    }
  }
}

void updateScreen() {
  lcd.clear();
  lcd.setCursor(0, 0);                    // first line
  lcd.print("Current Speed");
  lcd.setCursor(0, 1);                    // second ine
  lcd.print(velocity);
  lcd.print(" mph   ");     // extra spaces erase previous data
}
42  Using Arduino / Sensors / Re: Sensor indicator light reset on: July 29, 2012, 03:46:46 pm
That's interesting because I used your code with my changes (below) and it worked fine on my Uno.

Quote
Code:

pinMode(buttonPin3, INPUT_PULLUP);

...
Code:

if (reading3 == LOW)
43  Using Arduino / General Electronics / Re: What is the role of INPUT mode on Arduino ? on: July 29, 2012, 03:15:46 pm
Quote
What is the role of pin 8 ?

When the button is not being pressed, the wire connected to pin 8 is at ground because of the resistor.  Both leads of the resistor are at ground.  Pin 8 is grounded.

When the button is pressed, it connects 5 volts to one end of the resistor.  Now one lead of the resistor is at 5 volts and the other lead is at ground.  The wire connected to pin 8 is also connected to 5 volts.  It stays at 5 volts because the resistor value is so great (10,000 Ohms) that it won't let very much current pass to ground.  The 5 volt source from the Arduino can easily keep up and maintains the voltage at 5 volts.  Pin 8 is at 5 volts.

Pin 8 is acting as an input to the Arduino.  Various values can be put into the Arduino through pin 8.
44  Using Arduino / Sensors / Re: Sensor indicator light reset on: July 29, 2012, 02:46:42 pm
Code:
int buttonPin3 = 6;
...
Code:
pinMode(buttonPin3, INPUT);
...
Code:
reading3 = digitalRead(buttonPin3);
...
Code:
if (reading3 == HIGH) {            // check if the input is HIGH

With pin 6 set to INPUT on one side of the button, and a pull-down resistor on the other side of the button, how will digitalRead() ever be HIGH?  Try it like this:

Code:
pinMode(buttonPin3, INPUT_PULLUP);
...
Code:
if (reading3 == LOW)
45  Using Arduino / Sensors / Re: Band pass/block filter for a bubbler pressure level sensor on: July 29, 2012, 12:14:50 am
Quote
The goal is to measure absolute level and see wave action

I know you want a band pass filter but until you make one, here are a few more things you can try:

1. Run the pump at a very slow speed. Your goal does not require a high flow rate.
2. Pinch the tube or use an orifice to restrict the air flow to a bare minimum.
3. Put a large volume between the pump and the pressure sensor. It doesn't need to be absolutely airtight. Anything will do from a plastic bag to a bottle or can. An empty bong would work great if you have one.
4. For the vertical portion of the tube, use as large a diameter as feasible.
5. Soft silicone tubing would dampen vibrations better than hard PVC tubing.
6. A pump-up garden sprayer would work great if you have one.  No unwanted pulsations.
7. Depending on the depth of the water, you might be able to use a hair dryer for the air pump.
...

 
Pages: 1 2 [3] 4 5 ... 8