// The ES6937 Motion Sensing Swivel Disc - Getting Started... // We're going to use the serial plotter as an oscilloscope so that we can view the motion sensor waveform. Open the serial plotter as soon as you open the code. // CONNECTIONS: //AD3 is ground //AD1 is 5v //AD2 is PIR // The on-board LED is what we're going to use to see when the motion sensor output has become stable. No need to connect an external LED =) // The PCB connector pins are labelled AD1, AD2, and AD3. int hold = 0; // This integer will hold our Analog-to-digital data when sampling the motion sensor output void setup() { // Let's set things up Serial.begin(9600); // Start serial comms so that we can use the serial plotter or serial monitor pinMode(A3,OUTPUT); // Set analog pin#3 as an output. This will be set to LOW, and act as an artificial ground pinMode(A1,OUTPUT); // Set analog pin#1 as an output. This will be set to HIGH, and act as a power supply to the disc. The disc takes very little power to operate. digitalWrite(A3,LOW); // Greate the artificial ground by setting A3 LOW delay(1); // This 1ms delay is optional. digitalWrite(A1,HIGH);// Set A1 to high to apply 5v to the disc delay(1000); } // Doneski! void loop() { // We're going to use the serial plotter as an oscilloscope so that we can view the motion sensor waveform. Open the serial plotter as soon as you open the code. hold = analogRead(A2); // Sample the disc output and place the analog output value (0-1023) into hold. 1023 being 5v, 0 being 0v, and any value in between. Serial.println(hold); // Send the value to the serial monitor/plotter. delay(10); // Sample every 10ms. } // Notes: // Note the last line of code - delay(10); - This is the delay between each sample. For highest resolution, get rid of this delay all together. Make it longer for a loser resolution. // Seriously. Play with this delay to see how it changes the waveform on the serial plotter!