Show Posts
Pages: 1 [2] 3 4 ... 20
16  Using Arduino / Programming Questions / Re: encoder on: March 06, 2014, 02:41:10 pm
top people thanks  smiley-grin
17  Using Arduino / Programming Questions / encoder on: March 06, 2014, 02:11:46 pm
hi there I have this code what I got from here:  http://bildr.org/2012/08/rotary-encoder-arduino
what worked fine but in stead of counting in 1's I want to count in 0.1  how can I do this?

Code:

//these pins can not be changed 2/3 are special pins
int encoderPin1 = 2;
int encoderPin2 = 3;

volatile int lastEncoded = 0;
volatile long encoderValue = 0;

long lastencoderValue = 0;

int lastMSB = 0;
int lastLSB = 0;

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

  pinMode(encoderPin1, INPUT);
  pinMode(encoderPin2, INPUT);

  digitalWrite(encoderPin1, HIGH); //turn pullup resistor on
  digitalWrite(encoderPin2, HIGH); //turn pullup resistor on

  //call updateEncoder() when any high/low changed seen
  //on interrupt 0 (pin 2), or interrupt 1 (pin 3)
  attachInterrupt(0, updateEncoder, CHANGE);
  attachInterrupt(1, updateEncoder, CHANGE);

}

void loop(){
  //Do stuff here

  Serial.println(encoderValue);
  delay(1000); //just here to slow down the output, and show it will work  even during a delay
}


void updateEncoder(){
  int MSB = digitalRead(encoderPin1); //MSB = most significant bit
  int LSB = digitalRead(encoderPin2); //LSB = least significant bit

  int encoded = (MSB << 2) |LSB; //converting the 2 pin value to single number
  int sum  = (lastEncoded << 2) | encoded; //adding it to the previous encoded value

  if(sum == 0b1101 || sum == 0b0100 || sum == 0b0010 || sum == 0b1011) encoderValue ++;
  if(sum == 0b1110 || sum == 0b0111 || sum == 0b0001 || sum == 0b1000) encoderValue --;

  lastEncoded = encoded; //store this value for next time
}
18  Using Arduino / General Electronics / Re: attiny84 freezing on: March 06, 2014, 01:43:46 pm
hi there no I don't text them but when I'm next at site I will and we will see what we have
thanks again
Joe
19  Using Arduino / General Electronics / Re: attiny84 freezing on: March 01, 2014, 07:13:19 am
hi there I said I would post a pic and here we go





but I'm still having issues with it freezing so doe's any one have other suggesting?
only doing it about every 3-4 weeks
20  Using Arduino / General Electronics / Re: smd optocoupler on: February 23, 2014, 02:00:07 pm
ok thanks just looking at this one
http://uk.farnell.com/vishay-semiconductor/tcmd4000/optocoupler-transistor-o-p-3-75kv/dp/1469505RL
21  Using Arduino / General Electronics / smd optocoupler on: February 23, 2014, 01:14:34 pm
hi there
I have been using one of these Optocouplers and seem to work fine, but looking for a SMD Optocoupler now I no they do a smd of that opto but would like something smaller, does any one no of anything I could use?

http://uk.rs-online.com/web/p/products/6935952/
22  Using Arduino / General Electronics / Re: 3phase mains faliure circuit on: January 14, 2014, 04:20:56 pm
hehe I'm think im ok with 3 phase was I work with it 5 day a week.
just that I don't understand using a capacitor with a opto, and other people schematics I have seen have the phase going on to the opto and have the other leg of the opto go to the capacitor then the GND 

would you see any issues with using this opto as the PS2505-4 is not as available for me
http://uk.rs-online.com/web/p/optocouplers/6912218/
23  Using Arduino / Project Guidance / Re: multiple input monitoring on: January 14, 2014, 03:38:55 pm
I see now, ok thanks all for your help
24  Using Arduino / General Electronics / Re: 3phase mains faliure circuit on: January 14, 2014, 03:36:05 pm
ok thanks for that.
I am putting the x capacitor on the phase line not the ground?
25  Using Arduino / Project Guidance / Re: multiple input monitoring on: January 13, 2014, 01:23:30 pm
o I see, could I do this?

Code:
if (digitalRead(input1) && digitalRead(input2) && digitalRead(input3) && digitalRead(input4) && digitalRead(input5) && digitalRead(input6)) {   //check if any are high

26  Using Arduino / Project Guidance / Re: multiple input monitoring on: January 13, 2014, 01:08:12 pm
yes all that work's fine
27  Using Arduino / Project Guidance / Re: multiple input monitoring on: January 13, 2014, 12:48:56 pm
there is some other bits going on in here

Quote


//         ***  INPUT'S ***
const int input1   =  3;   
const int input2   =  2;   
const int input3   =  4;
const int input4   =  5;
const int input5   =  6;
const int input6   =  7;

//        *** LED OUTPUT'S ***
const int LED1     =  15;   
const int LED2     =  14;   
const int LED3     =  13;   
const int LED4     =  12;   
const int LED5     =  11; 
const int LED6     =  10;

//  *** LED/RESET/RELAY OUTPUT'S ***
const int Relay    =  8;
const int Reset    =  9;
const int LED      =  16;



int ledState = LOW;             // ledState used to set the LED
long previousMillis = 0;        // will store last time LED was updated
long interval = 1000;           // interval at which to blink (milliseconds)

void setup()
{
  //        ***  INPUT'S  ***
  pinMode(input1   ,    INPUT);
  pinMode(input2   ,    INPUT);
  pinMode(input3   ,    INPUT);
  pinMode(input4   ,    INPUT);
  pinMode(input5   ,    INPUT);
  pinMode(input6   ,    INPUT);

  //        ***  OUTPUT'S  ***
  pinMode(LED1    ,    OUTPUT);
  pinMode(LED2    ,    OUTPUT);
  pinMode(LED3    ,    OUTPUT);
  pinMode(LED4    ,    OUTPUT);
  pinMode(LED5    ,    OUTPUT);
  pinMode(LED6    ,    OUTPUT);

//  *** LED/RESET/RELAY OUTPUT'S *** 
  pinMode(Relay   ,    OUTPUT);
  pinMode(Reset   ,    INPUT);
  pinMode(LED     ,    OUTPUT);
 

}

void loop()  {
    unsigned long currentMillis = millis();        // LED  BLINKER
 
  if(currentMillis - previousMillis > interval) {
    // save the last time you blinked the LED
    previousMillis = currentMillis;   

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW)
      ledState = HIGH;
    else
      ledState = LOW;

    // set the LED with the ledState of the variable:
    digitalWrite(LED, ledState);
  }
 
 
  if (digitalRead(input1)==    LOW) {  // INPUT  1
    digitalWrite(LED1,        HIGH);
  }
 
  if (digitalRead(input2)==    LOW) {  // INTPUT  2
    digitalWrite(LED2,        HIGH);
  }
 
 
  if (digitalRead(input3)==    LOW) {  // INTPUT  3
    digitalWrite(LED3,        HIGH);
  }


  if (digitalRead(input4)==    LOW) {  // INTPUT  4
    digitalWrite(LED4,        HIGH);
  }


  if (digitalRead(input5)==    LOW) {  // INTPUT  5
    digitalWrite(LED5,        HIGH);
  }


  if (digitalRead(input6)==    LOW) {  // INTPUT  6
    digitalWrite(LED6,        HIGH);
  }

 
  if (input1 && input2 && input3 && input4 && input5 && input6) {    //check if any are high
   digitalWrite(Relay,        HIGH);
  }
  else {
   digitalWrite(Relay,        LOW);
  }

  if (digitalRead(Reset)==  HIGH) {  // Reset button
    digitalWrite(LED1,       LOW);
    digitalWrite(LED2,       LOW);
    digitalWrite(LED3,       LOW);
    digitalWrite(LED4,       LOW);
    digitalWrite(LED5,       LOW);
    digitalWrite(LED6,       LOW);
    }
 }
28  Using Arduino / Project Guidance / Re: multiple input monitoring on: January 13, 2014, 12:32:10 pm
ok thanks for that, I got this:
Code:
  if (input1 && input2 && input3 && input4 && input5 && input6) {        //check if any are high
   digitalWrite(Relay,        HIGH);
  }
  else {
   digitalWrite(Relay,        LOW);


it seam's to write the Relay High regardless of the input's any idea's
29  Using Arduino / General Electronics / Re: 3phase mains faliure circuit on: January 13, 2014, 12:06:59 pm
so what size capacitor would we be looking at?
30  Using Arduino / Project Guidance / multiple input monitoring on: January 12, 2014, 04:47:15 pm
Hi there
I have 6 inputs labelled as:
input1
input2
input3
input4
input5
input6
How can I get the arduino to look at all its six inputs and if any of them go low to write an output low?
 
Pages: 1 [2] 3 4 ... 20