Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Re: how to get digital 8bits data in the same and group the data in a digital value on: April 08, 2011, 06:44:35 am
johnwasser thx for your help . i found the result was 1111111 which was not the correct value from the decoder IC output. is it the shift occurred any problem?  My latest program is following: is it have any problem?

int dataPins[8] = {30,31,32,33,34,35,36,37};
int SELPin = 38; //set SEL pin
int OEPin = 39; //set OE pin
int value;
int valuelow ;
int valuehigh ;
void setup()
    {
      pinMode (SELPin, OUTPUT); //set SEL is output to control the decoder ic
   pinMode (OEPin, OUTPUT); // set OE做is output to control the decoder ic

    for (int i = 30; i<= 37; i++)
         pinMode(dataPins, INPUT);
         Serial.begin (9600);
   }

void loop()
   {
     digitalWrite(SELPin, HIGH); // SEL = 1    when SEL and OE are 1 that means tell the ic ready to give data
   digitalWrite(OEPin, HIGH); // OE = 1

   digitalWrite(SELPin, LOW); // SEL = 0   when SEL and OE are 0 that means tell the ic send the low 8 bits data
   digitalWrite(OEPin, LOW); // OE = 0

   valuelow=0;
   valuehigh=0;

   for (int i=30; i<=37; i++)
       {
       valuelow << 1;  // shift value left one bit
       valuelow |= digitalRead(dataPins);  // get a bit from a data pin
       }
/*     digitalWrite(SELPin, HIGH); // SEL = 1     when SEL is 1 and OE are 0 that means tell the ic send the high 8 bits data
   digitalWrite(OEPin, LOW); // OE = 0
     
      for (int i=30; i<=37; i++)
      {
        valuehigh <<= 1;  // shift value left one bit
       valuehigh |= digitalRead(dataPins);  // get a bit from a data pin
    }
   // value=(valuehigh*128)+valuelow;       */
    Serial.println(valuelow,BIN);
   }
2  Using Arduino / Programming Questions / how to get digital 8bits data in the same and group the data in a digital value on: March 30, 2011, 06:30:09 am
i uses HCTL-2020 for decoding the INCREMENTAL ROTARY encoder signal . it has 8 pins to provide a 8 bits data. i don't know how to get the data in the same time and group the data in a DEC value
Pages: [1]