Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void setup()
- {
- pinMode(2, INPUT);
- pinMode(13, OUTPUT);
- }
- void loop()
- {
- int ans;
- byte c[2];
- Wire.beginTransmission(SENSOR_ADRS);
- Wire.write(DISTANCE_ADRS);
- c[0] = 上位 11-4 ビットのテーブルアドレス;
- c[1] = 下位 3-0 ビットのテーブルアドレス;
- ans = ((c[0]*16+c[1]) / 16) / pow(2,0x02) ;
- if (ans < 100) {
- if (digitalRead(2) == HIGH) {
- digitalWrite(13, HIGH);
- Serial.println("Motion detected!");
- delay(50000);
- } else {
- digitalWrite(13, LOW);
- Serial.println("Motion end!");
- }
- } else {
- return(-1);
- }
- }
Add Comment
Please, Sign In to add comment