Loading...
  Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Re: bitWrite (0xFE, 15, 1); Does not compute (correctly) on: May 17, 2012, 11:51:48 pm

Yup that solved it ...  (unsigned int == 16bit Byte) ... lol

unsigned int VAR_NAME = 0xFFFF;

I thought i was having another issue and changed unsigned int to a byte ( hoping i could use 8 bits) but for some reason forgot it was only 8bits smiley not a 16bit register ...

Thank you.
2  Using Arduino / Programming Questions / (Solved) bitWrite (0xFE, 15, 1); Does not compute (correctly) on: May 17, 2012, 09:09:40 pm
Hello,

I'm running a ProMini and I'm seeing an unexpected result. Can someone please confirm if it's my code or the Arduino Mal-processing the result.

What i expect is to see in the register:
00000000 // Clear
then
00000001
00000011
...
00111111
01111111
11111111

But what i get is ...

00000000
then
00000001
00000011
...
00111111
01111111
-1               <--- WHAT THE, That's not 0xFF or B1111111?

What i see happening is when i try to bitWrite bit 15 to a 1 ... I get a overflow and not a 0xFF. Is this me or the Arduino?  (I also see variable containing the bit 15 change to bit 16?)

SOLUTION:
int LED_New_ShiftRegister = 255;
SHOULD BE:
unsigned int LED_New_ShiftRegister = 0xFFFF;



THANK YOU for any help!
Mr.Deek


------------------------
Clode Example Below:

Code:

int LED_New_ShiftRegister = 255;

void loop()
{

// Set the shift register to 00000000
for (int X=0; X<16; X++)
  {
    LEDModRegister(X, 0);
  };
  LEDShiftOut();
  delay(1000);

// Step the shift register +1 to 00000001 .. to 11111111
for (int X=0; X<16; X++)
  {
    LEDModRegister(X, 1);
    LEDShiftOut();
    delay(100);
  };

  delay(1000);
}


// Function
int LEDModRegister(int WhichLED, int LEDSTATE)
{
  Serial.print ("SHIFT1: ");
  Serial.print (WhichLED);
  Serial.print ("\n");
  bitWrite(LED_New_ShiftRegister, WhichLED, LEDSTATE);
  Serial.print ("SHIFT2: ");
  Serial.print (WhichLED);
  Serial.print ("\n");
  return true;
}
3  Development / Other Software Development / Re: Arduino simulator. on: May 17, 2012, 08:54:54 pm

I'm interested ... I'll be awaiting a beta version smiley

Thanks!
Pages: [1]