I have two Parallax H48C 3-axis accelerometer and I am using the example code found on the playground (http://playground.arduino.cc/Main/ParallaxH48C). The example code only supports one accelerometer but I wish to use two on the same arduino. After reading the data sheet it said I could use the same arduino I/O pins but I would have to run the CS pin to different arduino pins. My solution is to run them alternately by running the example once then increase a variable by one. If the number is even then CS = accelerometer1 but if the number is odd then CS = accelerometer2. I have tried this for several hours but I can't get my code to use the new CS pin number at every start.
Let me simplify this I DO have a way to change the number and I can see it change when I print it on serial but the code will not use the new number as the new CS pin number.
If someone can explain what's happening or if you can modify the example to incorporate two accelerometers running alternately that would be great
It looks like a normal SPI interface. So with two pins for CS, it should be possible.
The best way to make this work, is to create a class. If the class is created the pin for CS is copied into a variable in that class.
But I don't have a H48C sensor, so I can't make that class.
Can you please upload your code ?
(Use the button with the '#' above the text field for tags around your code).