User talk:Nihaopaul
ark sb401010k
1.6v 86ua of current 5v @ 22k resistor is quite dim, 60k resistor is about the same but much dimmer
rtc
http://item.taobao.com/item.htm?id=18571232760
xinchejian video
street side of xinchejian, view from outside looking up, pink lights, show the enterance way and door way get the view of the windows on the streets
overview, narrated by Ricky and Minlin, "interview to xinchejian" standing, in "un"shared area, remember to say hi to hack-a-day.
Mac-hine room tour/reprap by Paul and Valentin, lio & edward appear to talk about the door lock(s)
Introduction to the Urban farming, roger or David and Jia-qi
20 second intro to our neighbors
Catch a Wednesday presentation
View of the roof as the sun is setting.. mad lighting in the soldering area.
stc digital compas mkz51
http://www.grappendorf.net/arduino/libraries/cmps03-compass-module
i2c - should be i2c but really it's spi :/
MAG1130
#include <Wire.h>
#define MAG_ADDR 0x0E //7-bit address for the MAG3110, doesn't change
int xmax, xmin, ymax, ymin, zmax,zmin = 0; //offsets
void setup()
{
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600); // start serial for output
config(); // turn the MAG3110 on
}
void loop()
{
print_values();
delay(5);
}
void config(void)
{
Wire.beginTransmission(MAG_ADDR); // transmit to device 0x0E
Wire.write(0x11); // cntrl register2
Wire.write(0x80); // send 0x80, enable auto resets
Wire.endTransmission(); // stop transmitting
delay(15);
Wire.beginTransmission(MAG_ADDR); // transmit to device 0x0E
Wire.write(0x10); // cntrl register1
Wire.write(1); // send 0x01, active mode
Wire.endTransmission(); // stop transmitting
}
void print_values(void)
{
Serial.print("x=");
Serial.print(readx());
Serial.print(",");
Serial.print("y=");
Serial.print(ready());
Serial.print(",");
Serial.print("z=");
Serial.println(readz());
}
int calibrate_x(int in) {
/* we need to calibrate it for the offset in this part of the world */
xmax = max(xmax, in);
xmin = min(xmin, in);
int offset = ( (xmax + xmin) / 2 );
return in - offset ;
}
int calibrate_y(int in) {
/* we need to calibrate it for the offset in this part of the world */
ymax = max(ymax, in);
ymin = min(ymin, in);
int offset = ( (ymax + ymin) / 2 );
return in - offset;
}
int calibrate_z(int in) {
/* we need to calibrate it for the offset in this part of the world */
zmax = max(zmax, in);
zmin = min(zmin, in);
int offset = ( (zmax + zmin) / 2 );
return in - offset;
}
int readx(void)
{
int xl, xh; //define the MSB and LSB
Wire.beginTransmission(MAG_ADDR); // transmit to device 0x0E
Wire.write(0x01); // x MSB reg
Wire.endTransmission(); // stop transmitting
delayMicroseconds(2); //needs at least 1.3us free time between start and stop
Wire.requestFrom(MAG_ADDR, 1); // request 1 byte
while(Wire.available()) // slave may send less than requested
{
xh = Wire.read(); // receive the byte
}
delayMicroseconds(2); //needs at least 1.3us free time between start and stop
Wire.beginTransmission(MAG_ADDR); // transmit to device 0x0E
Wire.write(0x02); // x LSB reg
Wire.endTransmission(); // stop transmitting
delayMicroseconds(2); //needs at least 1.3us free time between start and stop
Wire.requestFrom(MAG_ADDR, 1); // request 1 byte
while(Wire.available()) // slave may send less than requested
{
xl = Wire.read(); // receive the byte
}
int xout = (xl|(xh << 8)); //concatenate the MSB and LSB
return calibrate_x(xout);
}
int ready(void)
{
int yl, yh; //define the MSB and LSB
Wire.beginTransmission(MAG_ADDR); // transmit to device 0x0E
Wire.write(0x03); // y MSB reg
Wire.endTransmission(); // stop transmitting
delayMicroseconds(2); //needs at least 1.3us free time between start and stop
Wire.requestFrom(MAG_ADDR, 1); // request 1 byte
while(Wire.available()) // slave may send less than requested
{
yh = Wire.read(); // receive the byte
}
delayMicroseconds(2); //needs at least 1.3us free time between start and stop
Wire.beginTransmission(MAG_ADDR); // transmit to device 0x0E
Wire.write(0x04); // y LSB reg
Wire.endTransmission(); // stop transmitting
delayMicroseconds(2); //needs at least 1.3us free time between start and stop
Wire.requestFrom(MAG_ADDR, 1); // request 1 byte
while(Wire.available()) // slave may send less than requested
{
yl = Wire.read(); // receive the byte
}
int yout = (yl|(yh << 8)); //concatenate the MSB and LSB
return calibrate_y(yout);
}
int readz(void)
{
int zl, zh; //define the MSB and LSB
Wire.beginTransmission(MAG_ADDR); // transmit to device 0x0E
Wire.write(0x05); // z MSB reg
Wire.endTransmission(); // stop transmitting
delayMicroseconds(2); //needs at least 1.3us free time between start and stop
Wire.requestFrom(MAG_ADDR, 1); // request 1 byte
while(Wire.available()) // slave may send less than requested
{
zh = Wire.read(); // receive the byte
}
delayMicroseconds(2); //needs at least 1.3us free time between start and stop
Wire.beginTransmission(MAG_ADDR); // transmit to device 0x0E
Wire.write(0x06); // z LSB reg
Wire.endTransmission(); // stop transmitting
delayMicroseconds(2); //needs at least 1.3us free time between start and stop
Wire.requestFrom(MAG_ADDR, 1); // request 1 byte
while(Wire.available()) // slave may send less than requested
{
zl = Wire.read(); // receive the byte
}
int zout = (zl|(zh << 8)); //concatenate the MSB and LSB
return calibrate_z(zout);
}