Show Posts
Pages: [1] 2 3 4
1  Using Arduino / Project Guidance / Re: Measure time for a tank to empty by weight on: February 16, 2011, 12:21:04 pm
SORRY BUSY WITH SCHOOL.

I have more info on this project. I'm actually working on it for a friend.

The "tank" is a BBQ LP tank. Wants to be able to tell ow much time would be left on a tank down nearest +/- 5 minutes. Has to be able to work with high, low, medium and any combination of heat settings to give an estimated time left on that tank.
2  Using Arduino / Project Guidance / Re: Measure time for a tank to empty by weight on: February 13, 2011, 04:42:23 am
I am having a bit of an issue.

This is as far as I have gotten. Basically a renamed version of the AnalogRead

Can some one point me to an example where I can store and recall values?
Trying to get a button to store the read value.

Code:
int weightsensor = 0;                       
int read_weight  = 0;

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  read_weight = analogRead(weightsensor);   
  Serial.println(read_weight);   
  delay(500); 
}

3  Using Arduino / Project Guidance / Re: Motor Twitching - Using Motor Shield on: February 08, 2011, 10:22:02 pm
Fell free to build off my code if you want. Its what i used for my mecanum robot. http://arduino.cc/forum/index.php/topic,17451.msg127229.html#msg127229

Code:
#include <AFMotor.h>  // imported AFMotor library

    AF_DCMotor motor1(1);   
    AF_DCMotor motor2(2);   
    AF_DCMotor motor3(3);   
    AF_DCMotor motor4(4);       
   
    void setup() {
     
    }   

    void loop() {
      int speed = analogRead(2);
      speed = map(speed, 0, 1023, -255, 255);
  if (speed < 0)
    {
      motor2.run(FORWARD);
      motor2.setSpeed(abs(speed));   
      motor3.run(FORWARD);
      motor3.setSpeed(abs(speed)); 
    }
  if (speed > 0)
    {
      motor2.run(BACKWARD);
      motor2.setSpeed(speed);
      motor3.run(BACKWARD);
      motor3.setSpeed(speed);
    }
    int speed2 = analogRead(3);
      speed2 = map(speed2,  0, 1023, -255, 255);
  if (speed2 < 0)
    {
      motor1.run(FORWARD);
      motor1.setSpeed(abs(speed2));
      motor4.run(FORWARD);
      motor4.setSpeed(abs(speed2));   
    }
  if (speed2 > 0)
    {
      motor1.run(BACKWARD);
      motor1.setSpeed(speed2);
      motor4.run(BACKWARD);
      motor4.setSpeed(speed2);
    }
   
  }

4  Using Arduino / Project Guidance / Re: Measure time for a tank to empty by weight on: February 08, 2011, 03:50:15 pm
Guess it would read that the tank is emptying faster than it was.
5  Using Arduino / Project Guidance / Measure time for a tank to empty by weight on: February 08, 2011, 03:36:22 pm
using either a modified bathroom scale or loadcell to measure the weight of a container for the full weight. Then have it calculate how long it would take to become empty.

Something like change in weight over every 5 seconds, then calculate that amount into the original wight to how long it would take at that rate for it to become completely empty. In either a amount of time left or a percentage of what is remaining in the tank.

I think it is possible, but maybe more math is involved.
6  Forum 2005-2010 (read only) / Interfacing / Re: Mecanum Drive (Adafruit Motor Shield) on: May 04, 2010, 01:36:59 pm
Here is a video of the side-to-side testing.

[media]http://www.youtube.com/watch?v=riWGafaGTV0[/media]
[size=10]I was the camera man, another guy with no experience was controlling it.[/size]

And the code for that part.

Code:
   #include <AFMotor.h>  // imported AFMotor library

    AF_DCMotor motor1(1);  
    AF_DCMotor motor2(2);    
    AF_DCMotor motor3(3);  
    AF_DCMotor motor4(4);      
    
    void setup() {
      
    }  

    void loop() {
      int speed = analogRead(2);
      speed = map(speed, 0, 1023, -255, 255);
  if (speed < 0)
    {
      motor2.run(FORWARD);
      motor2.setSpeed(abs(speed));  
      motor3.run(BACKWARD);
      motor3.setSpeed(abs(speed));  
    }
  if (speed > 0)
    {
      motor2.run(BACKWARD);
      motor2.setSpeed(speed);
      motor3.run(FORWARD);
      motor3.setSpeed(speed);
    }
    int speed2 = analogRead(3);
      speed2 = map(speed2,  0, 1023, -255, 255);
  if (speed2 < 0)
    {
      motor1.run(BACKWARD);
      motor1.setSpeed(abs(speed2));
      motor4.run(FORWARD);
      motor4.setSpeed(abs(speed2));  
    }
  if (speed2 > 0)
    {
      motor1.run(FORWARD);
      motor1.setSpeed(speed2);
      motor4.run(BACKWARD);
      motor4.setSpeed(speed2);
    }
    
  }
   
7  Forum 2005-2010 (read only) / Interfacing / Re: Mecanum Drive (Adafruit Motor Shield) on: April 20, 2010, 11:50:55 pm
I got more help from the Adafruit forms.

Video http://www.flickr.com/photos/20102150@N06/4538224965/?processed=1&cb=1271792057427

Basic tank steering.

Code:

    #include <AFMotor.h>  // imported AFMotor library

    AF_DCMotor motor(3);  
    AF_DCMotor motor1(4);      
    
    void setup() {
      
    }  

    void loop() {
      int speed = analogRead(1);
      speed = map(speed, 0, 1023, -255, 255);
  if (speed < 0)
    {
      motor.run(BACKWARD);
      motor.setSpeed(abs(speed));  
    }
  if (speed > 0)
    {
      motor.run(FORWARD);
      motor.setSpeed(speed);
    }
    int speed2 = analogRead(0);
      speed2 = map(speed2, 0, 1023, -255, 255);
  if (speed2 < 0)
    {
      motor1.run(BACKWARD);
      motor1.setSpeed(abs(speed2));  
    }
  if (speed2 > 0)
    {
      motor1.run(FORWARD);
      motor1.setSpeed(speed2);
    }
    
  }  

 
8  Forum 2005-2010 (read only) / Interfacing / Re: Mecanum Drive (Adafruit Motor Shield) on: April 19, 2010, 08:50:53 pm
This is what I have working so far.

    
Code:
#include <AFMotor.h>  // imported AFMotor library

    AF_DCMotor motor(3);  

    
    int SPEED = 0;
    int val = 0;

    void setup() {
       Serial.begin(9600);
    

      motor.run(RELEASE);
      delay(50);

      
      }
    void moveForward() {
      motor.run(FORWARD);
        motor.setSpeed(SPEED);
        Serial.print(" ");
        Serial.print( SPEED);
    }

    void moveBackward() {
      motor.run(BACKWARD);
        motor.setSpeed(SPEED);
        Serial.print(" ");
        Serial.print( SPEED);

    }

    void loop() {
      int val = analogRead(1);
        if (val > 540) {
        // move faster the higher the value from the potentiometer
        SPEED = 2048 - 1024 * val / 512 + 1;
        moveForward();
        
      } else if (val < 480) {
        // move faster the lower the value from the potentiometer
        SPEED = 1024 * val / 512 + 1;
        moveBackward();
        
      } else {
        motor.run(RELEASE);
      }

My values are off. Mid point between forward and middle and backward and middle are the high speeds. modifying it for 2 joysticks makes it very buggy, but usable.
9  Forum 2005-2010 (read only) / Interfacing / Re: Mecanum Drive (Adafruit Motor Shield) on: April 18, 2010, 03:15:00 am
Just analog joysticks pulled from a old PS1 controller. 2.5K or so.


http://www.flickr.com/photos/20102150@N06/4494809794/in/set-72157623717071761/

10  Forum 2005-2010 (read only) / Interfacing / Mecanum Drive (Adafruit Motor Shield) on: April 18, 2010, 02:35:25 am
I have started a little backwards on this and have designed the wheels before starting on my actual sketch.

3d-printable_mecanum_wheel Well it is a set, not just one wheel.

I plan to control this using 2 analog joysticks for all of the movement.

Question is how do I control motor direction on the Adafruit motor shield using a analog joystick? I have seen examples for the motor shield on using it for PIR robots, but more of a motor forward motor backwards. I want speed control.
11  Forum 2005-2010 (read only) / Interfacing / Re: Set time on DS1307 with a keypad. on: February 24, 2010, 03:09:39 am
Anybody know how to combine the two?

Wanting to use part of the code used in this.

Code:
//
// Maurice Ribble
// 4-17-2008
// http://www.glacialwanderer.com/hobbyrobotics

// This code tests the DS1307 Real Time clock on the Arduino board.
// The ds1307 works in binary coded decimal or BCD.  You can look up
// bcd in google if you aren't familior with it.  There can output
// a square wave, but I don't expose that in this code.  See the
// ds1307 for it's full capabilities.

#include "Wire.h"
#define DS1307_I2C_ADDRESS 0x68

// Convert normal decimal numbers to binary coded decimal
byte decToBcd(byte val)
{
  return ( (val/10*16) + (val%10) );
}

// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val)
{
  return ( (val/16*10) + (val%16) );
}

// Stops the DS1307, but it has the side effect of setting seconds to 0
// Probably only want to use this for testing
/*void stopDs1307()
{
  Wire.beginTransmission(DS1307_I2C_ADDRESS);
  Wire.send(0);
  Wire.send(0x80);
  Wire.endTransmission();
}*/

// 1) Sets the date and time on the ds1307
// 2) Starts the clock
// 3) Sets hour mode to 24 hour clock
// Assumes you're passing in valid numbers
void setDateDs1307(byte second,        // 0-59
                   byte minute,        // 0-59
                   byte hour,          // 1-23
                   byte dayOfWeek,     // 1-7
                   byte dayOfMonth,    // 1-28/29/30/31
                   byte month,         // 1-12
                   byte year)          // 0-99
{
   Wire.beginTransmission(DS1307_I2C_ADDRESS);
   Wire.send(0);
   Wire.send(decToBcd(second));    // 0 to bit 7 starts the clock
   Wire.send(decToBcd(minute));
   Wire.send(decToBcd(hour));      // If you want 12 hour am/pm you need to set
                                   // bit 6 (also need to change readDateDs1307)
   Wire.send(decToBcd(dayOfWeek));
   Wire.send(decToBcd(dayOfMonth));
   Wire.send(decToBcd(month));
   Wire.send(decToBcd(year));
   Wire.endTransmission();
}

// Gets the date and time from the ds1307
void getDateDs1307(byte *second,
          byte *minute,
          byte *hour,
          byte *dayOfWeek,
          byte *dayOfMonth,
          byte *month,
          byte *year)
{
  // Reset the register pointer
  Wire.beginTransmission(DS1307_I2C_ADDRESS);
  Wire.send(0);
  Wire.endTransmission();

  Wire.requestFrom(DS1307_I2C_ADDRESS, 7);

  // A few of these need masks because certain bits are control bits
  *second     = bcdToDec(Wire.receive() & 0x7f);
  *minute     = bcdToDec(Wire.receive());
  *hour       = bcdToDec(Wire.receive() & 0x3f);  // Need to change this if 12 hour am/pm
  *dayOfWeek  = bcdToDec(Wire.receive());
  *dayOfMonth = bcdToDec(Wire.receive());
  *month      = bcdToDec(Wire.receive());
  *year       = bcdToDec(Wire.receive());
}

void setup()
{
  byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
  Wire.begin();
  Serial.begin(9600);

  // Change these values to what you want to set your clock to.
  // You probably only want to set your clock once and then remove
  // the setDateDs1307 call.
  second = 45;
  minute = 3;
  hour = 7;
  dayOfWeek = 5;
  dayOfMonth = 17;
  month = 4;
  year = 8;
  setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year);
}

void loop()
{
  byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;

  getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
  Serial.print(hour, DEC);
  Serial.print(":");
  Serial.print(minute, DEC);
  Serial.print(":");
  Serial.print(second, DEC);
  Serial.print("  ");
  Serial.print(month, DEC);
  Serial.print("/");
  Serial.print(dayOfMonth, DEC);
  Serial.print("/");
  Serial.print(year, DEC);
  Serial.print("  Day_of_week:");
  Serial.println(dayOfWeek, DEC);

  delay(1000);
}

Too use the Keypad to set this section?

 
Code:
 // Change these values to what you want to set your clock to.
  // You probably only want to set your clock once and then remove
  // the setDateDs1307 call.
  second = 45;
  minute = 3;
  hour = 7;
  dayOfWeek = 5;
  dayOfMonth = 17;
  month = 4;
  year = 8;
  setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year);
12  Forum 2005-2010 (read only) / Interfacing / Set time on DS1307 with a keypad. on: February 23, 2010, 02:20:37 am
I am getting too side tracked on the LED clock that I am making by wanting to  add more stuff to it.  Newest purchase is a eBay find at $12. A vandal resistant keypad, Storm Industries series 1000. Its clipped into 3 shields and propped up with a Sparkfun box.  A very heavy and sturdy keypad around 2-3 pounds.

http://www.flickr.com/photos/20102150@N06/4380812531/


I have seen a video on YouTube that shows a guy setting the time on a DS1307 with a keypad. It is very vague in description and used 4 buttons. Has anyone tired doing something like this? I am not finding much info on how to go about this.

Idea from this also.
http://blog.makezine.com/archive/2007/10/alarm_clockcountdown_time_1.html
13  Forum 2005-2010 (read only) / Interfacing / Re: Value of the "pedals" on a game controll on: December 28, 2009, 05:54:22 pm
Its potentiometers in series.

Click to enlarge

The multimeter shows a value of 41.3k ohms at rest. Pressing gas lowers it to 0 ohms. Pressing break raises it to 81.7k ohms. Pressing both pedals gives 40.4k ohms
14  Forum 2005-2010 (read only) / Interfacing / Re: Value of the "pedals" on a game controll on: December 28, 2009, 05:37:02 am
Not so sure if that will will work.

[glow]Using a pull down resistor[/glow].Value reads 0. Pressing the gas I get 980. Pressing the break does nothing. Pressing on both brings it back to 0.

[glow]Using a pull up resistor[/glow]. Value reads 1022. Pressing gas lowers to 46. Pressing Break does nothing. Pressing both brings it back to 1022.


Code:
int potVar = 0;

void setup() {
Serial.begin(9600);
pinMode(11, OUTPUT);
}

void loop() {
//read the voltage on the potentiometer:
potVar = analogRead(0);
//print the value out:
Serial.println(potVar, DEC);
//slight pause
delay(10);
//dim the LED. since the resolution of the input is 10bit and the output(1024)
//is only 8bit (255) we need to divide potVar by 4 to get the right range
analogWrite(11,potVar/4);
}
15  Forum 2005-2010 (read only) / Interfacing / Value of the "pedals" on a game controller. on: December 28, 2009, 04:34:44 am
I am still learning how to use the arduino after finally getting it to work after 5 months.

I have an old Alalog steering wheel game controller with pedals (Mad Catz 5320) that I would eventually like to get working with the Arduino. The pedals are separate and I can easily hook them up to an analog pin. It works on 2 potentiometers in series. I guess it is a average value and pressing the break raises the resistance and pressing the gas lowers the resistance?

How would I be able to read the value and display it with LED brightness with blue for gas and red for break?

I was using this basic code just to test it.
Code:
#define LED  9  // the pin for the LED

int val = 0;    

void setup() {

  pinMode(LED, OUTPUT);
  
}

void loop() {

  val = analogRead(0);

  analogWrite(LED, val/4)
 
  delay(10);
            
}
Pages: [1] 2 3 4