| Arduino Forum ::  Members :: spencer2004
 Show Posts Pages: [1]
 1 Using Arduino / Project Guidance / Re: speedometer on: July 12, 2013, 05:25:00 am I am currently doing the same thing. The way mine works is I have a magnet on a wheel and a hall effect sensor within range of the magnet, when the magnet passes the hall effect sensor it triggeres an interupt which records the time it happened (millis), the second time this happens the second time is recorded, the interupt is disabled, the time difference is calculated in void loop() when it gets the chance, 60000 is divided by the time difference to get the rph (revolutions per hour) of the wheel, times that by the circumference of the wheel in miles to get the mph. This could work with other sensors like a photointerrupter or something but I would think that they would be quite vulnerable to dirt and other debris in a gocarting enviroment.Here is the code for calculating MPH and KPHCode:volatile long pulse1 = 0;volatile long pulse2 = 0;volatile byte speedReadingCount = 0;int rpm;int mph;int kph;void pulse_detect(){  pulse2 = pulse1;  pulse1 = millis(); //record latest interrupt time  speedReadingCount++; //increase the reading counter  if(speedReadingCount == 2){ //if 2 readings have been made...    detachInterrupt(0); //detach interrupt  }}void setup(){attachInterrupt(0, pulse_detect, FALLING); //attach interupt on the falling edge on digital pin 2 (for uno and mega)}void loop(){  //mph calculation  if(speedReadingCount == 2){ //if the 2 times have been recorded...    pulsetime = pulse1 - pulse2; //calculate the time between pulses      rpm = 60000 / pulsetime; //RPM = 60000 / time between pulses      mph = ((rpm * 60) * wheelCir); //Speed = the RPH of the front wheel times the wheel circumference in miles      kph = (mph / 0.62137); //convert to kph    speedReadingCount = 0; //reset the reading counter    attachInterrupt(0, pulse_detect, FALLING); //re-attach the interrupt  }  if ((millis() - pulse1) >= 2000){ //If a pulse is not registered for 2 second / 2000ms it is assumed that the wheel is not moving    mph = 0;    kph=0;    speedReadingCount = 0;  }}
 2 Using Arduino / Programming Questions / Re: Using digital pins 0 and 1 on: July 11, 2013, 06:07:25 pm Thanks for the quick replies. I guess I'll use them as outputs then.
 3 Using Arduino / Programming Questions / Using digital pins 0 and 1 on: July 11, 2013, 05:57:41 pm I am currently working on a fairly complicated project at the moment which uses all but one pin on my Arduino Uno so I'm having to use digital pins 0 and 1 as inputs but for some reason I cannot get digital pin 0 to work whereas pin 1 works fine. Digital pin 0 seems to read high all the time but I cannot check as serial obviously wont work with pins 1 and 2 in use. The pins are being used to detect a signal from a hall effect sensor to find the position of 2 servo motors, the inputs have 10k pull-down resistors on them.Here is the code that reads the pins, it is run in void setup()Code:void calibrateMotors(){  boolean calibrated = 0;   motor1pos = 4096; //pretend that the motors are 4096 steps ahead of 0   motor2pos = 4096;   while(calibrated == 0){ if(digitalRead(0) == HIGH){ //if input is high...  motor1pos = 0; //motor is zeroed }  if(digitalRead(1) == HIGH){  motor2pos = 0; }if(motor1pos == 0 && motor2pos == 0){ //if both motors are calibrated... calibrated = 1; //end the while loop}else{ stepperMove(0,0,1);  //otherwise move the motor(s) back a step if they arent zeroed yet} }}The pins are declared as inputs in void setup() before the code is run. Serial is not used anywhere else in the program.So am I missing something really obvious here? I could not find any special requirments for using digital pins 0 and 1.
 4 Using Arduino / LEDs and Multiplexing / Re: MAX7219 and Common Anode displays with LedControl on: May 09, 2013, 07:32:10 am Quote from: luponero76 on May 06, 2013, 02:15:31 amhican you help me how to applicate de patch without hunk error?i work under mac with unixthank you dd.I forgot how I did it but here are the patched files. Just extract it in to your LedControl folder.
 5 Using Arduino / LEDs and Multiplexing / Re: MAX7219 and Common Anode displays with LedControl on: May 03, 2013, 01:42:38 pm ok I have got it working perfectly but I am having some confusion with the value for the ISET resistor; I origionally used a 28k ohm resistor which is what the data sheet recommends but the 7 segment display was fairly dim so I tested it with a multimeter and each segment was drawing only 2 mA so I played around with the resistance value and I finally got each segment to run at 10 mA with a value of 2.2k which is much lower than it should be. Is it possible that using the MAX7219 as a common anode display driver drasticaly changes the value required for the ISET resistor?I made sure that the software brightness control was at the maximum value of 15 and I have no resistors between the IC and the 7 segment display by the way.Edit: Each segment draws 10mA only when 1 digit is activated, they progressively draw less current and get dimmer as more digits are activated until they only draw 4.25mA with all 8 digits activated, strangely the current draw per segment is unaffected if other segments on the same digit are activated (e.g. displaying a number 1 draws 20mA, a number 8 draws 70mA).
 6 Using Arduino / LEDs and Multiplexing / Re: MAX7219 and Common Anode displays with LedControl on: May 02, 2013, 04:09:03 pm Never mind I finally got it to work. It literally took me the whole day to figure it out!
 7 Using Arduino / LEDs and Multiplexing / Re: MAX7219 and Common Anode displays with LedControl on: May 02, 2013, 03:30:04 pm I need to drive an 8 digit common anode 7 seg display.I have sort of figured out how to patch it but I can't get it to work; I patched the source file with GnuWin32 and it almost works but it says that hunk #4 failed at 219 whereas hunk 1, 2, 3 and 5 are successful. It says that I should use the -p or --strip option but I don't know how they work.Would it be possible for somebody to upload the patched source file? It would be of great help.
 8 Using Arduino / LEDs and Multiplexing / Re: MAX7219 and Common Anode displays with LedControl on: May 02, 2013, 09:43:32 am Hi, sorry for my ignorence but how do I patch the origional ledControl libary with the common-anode patch? I tried to find out how to do it on Google but I couldn't find anything.
 Pages: [1]