Loading...
  Show Posts
Pages: 1 [2]
16  Using Arduino / Programming Questions / disable a button input unitll another pressed on: August 23, 2011, 06:00:59 am
Hello every one, any suguestions, smiley

As you may see by my sketch, this has three buttons, foward, stop reverse, when press forward run till count is reached then stops, same when press reverse, one question if moves forward and stops when count reached , how can i prevent from moving forward again, and  the only direction allowed to move is reverse.


#include <Button.h>
#include <EEPROM.h>                  // 23/8/11


Button in = Button(4,PULLUP);        // keeps pin 4 high waitng for low to trip
Button halt = Button(5,PULLUP);      // keeps pin 5 high waiting for low o trip
Button out = Button(6,PULLUP);       // keeps pin 6 high waiting for low to trip

int pulsePin = 3;                  // hall effetc input pin 3
unsigned long counter = 0; 
unsigned long duration = 0; 
unsigned long timeout = 1000000; // in microseconds
unsigned long howfar = 400;       // how far to travel till stops motor
int value;

 

 void setup(){
EEPROM.write(1,howfar);    // 23/8/11 write value of howfar to eeprom loaction 1

value = EEPROM.read(1);   // read eeprom address 1 and call it value


   
pinMode (13,OUTPUT);                                                //  new 17/08/11  use led on pcb to warn that calibration about to start
pinMode(11,OUTPUT);                                                // changes direction of motor
pinMode(10,OUTPUT);                                                // turns main relay power on
pinMode(pulsePin, INPUT);       
digitalWrite(pulsePin, HIGH);                                       // enable the 20K pull-up resistor to steer the input pin to a HIGH reading.
Serial.begin(9600);                                                // open serial port
}

void loop(){

if(in.isPressed()){digitalWrite(10,HIGH);                          //   forward switch
digitalWrite(11,LOW) ;} 

if(halt.isPressed()){digitalWrite(10,LOW);}                          // stop switch

if(out.isPressed()){digitalWrite(10,HIGH);                         // reverse switch
digitalWrite(11,HIGH);}
                                             
                                               // calabration start here, eg move motor back till end stop reached, reset counter 2 , move motor till other end
                                                // stop reached, memorise total count, return motor back to start position,
                                               
duration = pulseIn(pulsePin, HIGH, timeout);
if (duration == 0) {   

Serial.println(""); 
} else {   

counter++;
Serial.print(counter);                                                         // so i can monitor count pulses etc in serial monitor
Serial.println("");


if (digitalRead(11) == HIGH  && (counter>=value)){                            // if count reached, checks where relays are
digitalWrite(11,LOW);                                                         // reverse polarty for 10ms then turns pwr relay off.
delay(10);                                                                   // need this to stop 1 pulse ove count to prevet run on
digitalWrite(10,LOW);
}
else 
{
if(digitalRead(11) == LOW  && (counter>=value)){                            // if count reached checks relays for polarity and switches
digitalWrite(11,HIGH);                                                       // them in reverse for 10ms, then turns pwr relay off.
delay(10);                                                                  // need this to stop over run from count that stops on
digitalWrite(10,LOW);};

if(counter>=value){                           //reset counter when distance reached
counter = 0;                                           

}}} }



 
17  Using Arduino / Project Guidance / Re: TABS on: July 20, 2011, 04:09:32 am
would this work ?if  i had a switch control sketch that work great, i would make a tab and call it switch.h , than add Include switch.h into main sketch, would this work?

i would like to keep the main sketch clean.
18  Using Arduino / Project Guidance / TABS on: July 20, 2011, 03:31:49 am
i am new, can any one point me in the right direction.

Can you place a different sketch into a different TABs,so they will compile together?

What do you do about the 2 VOID SETUP in both sketches.
19  Using Arduino / Project Guidance / Re: "YOUR BOAT IS SINKING" SMS FROM IPHONE CONTROLLED BY ARDUINO on: June 22, 2011, 06:41:39 am
look at this

http://techome.com.au/process/shop/productView.html?itemId=11128
20  Using Arduino / Project Guidance / Re: watching pin state change and if stops change turns motor off on: June 19, 2011, 04:31:58 am
thanks fast reply.

my pulse is 6 pulses per mm of travel ( an linerar actuator), about 9 mm travel  per sec
21  Topics / Home Automation and Networked Objects / Re: Iphone control program over network: someone interested? on: June 19, 2011, 04:28:44 am
hello, it good to have great idear that keep the brain ticking over, good on you.

I have had a few people ask how they can  open  or close  windows or blinds, turn on/off lights, turn of a heater or air conditioner etc,

But i am not a apple person.
22  Using Arduino / Motors, Mechanics, and Power / Re: Linear Actuator Control on: June 19, 2011, 04:07:30 am
i have 6 pulses per mm of travel.

using internal limits switches for safety

current limit very easy just using a voltage divider on a analogue input.
23  Using Arduino / Project Guidance / watching pin state change and if stops change turns motor off on: June 19, 2011, 04:04:32 am
Hello all, any help would be great.

i am using

int pulsePin = 3;   //motor hall effect input

how can i do a small sketech to check this is changing state and when stops changing state turns a motor off ?



24  Using Arduino / Motors, Mechanics, and Power / Re: Linear Actuator Control on: June 05, 2011, 01:56:32 am
yes i am going to use a mosfet h-bridge for control, just looking for any help on where to start, or if any one had a sketch similar i could adjust to suit .

i will also be using the built in end position switches and as extra safety use current sensing and a time out function as a back up ( must get the position part going first )

can you point me i a direction ?

25  Using Arduino / Motors, Mechanics, and Power / Re: Linear Actuator Control on: June 05, 2011, 01:25:14 am
http://www.timotion.tw/product_01_actuator.php

The Actuator is the TA2 

with hall sensor fitted.

Great unit in Australia contact www.techome.com

hope this helps
26  Using Arduino / Motors, Mechanics, and Power / Linear Actuator Control on: June 04, 2011, 10:56:56 pm
Hello All , newbie here.

I have just started with arduino and was look to see if the might be a sketch around that would read the pulses from a linear actuator encoder and allow the actuator to only move a preset distance determined by the pulses counted.  eg  a 300mm actuatore and only want it to move 275mm.
27  Using Arduino / Programming Questions / motor driven water pump for cooling a still on: May 22, 2011, 05:52:00 am
Hi all New Bee here,

i have a temp sensor that will monitor the still temperature and will turn the pump on/off with pin 6 PWM driving a FET.

My problem, The PWM seems 25% on or fully on , nothing in between. would like so is slow then get faster, or fast then slow down , but my PWN

I my code below, it is a mix of my own and some else s i have modded
any tips?




Pages: 1 [2]