Hardware Reference
In-Depth Information
Then, in the loop() part of the sketch, we read out the state of the motion sensor using a
simple digitalRead() command, and store that result into a variable. This state is
then simply printed out on the serial port every 100 ms.
You can now upload the sketch to your Arduino board and open the serial monitor. This is
what you should see:
Motion sensor state:0
Motion sensor state:1
Motion sensor state:1
Motion sensor state:1
Motion sensor state:0
Motion sensor state:0
If you can see the state of the sensor changing when you wave your hand in front of it, it
means that the sensor is working correctly and that you can proceed to the rest of the pro-
ject.
Search WWH ::




Custom Search