State: what can be its definition?
Anything which holds the current data of a thing, place or person.
But state with reference to motion can toggle only between two states moving and still.
What if I say we can convert these state into binary to control things.
What if I say that you can switch on your bulb by moving your hand slightly upward rather than switch?
Yes we can!
Project Description:
It is a simple but interested project to print values of X, Y, Z co-ordinates depending on how you change the sensor orientation.
Let's start, we will need:
Steps:
Step 1:
Connecting accelerometer module gy-61 with Arduino
Accelerometer module contains 5 pins:
Connections:
Step 2:
Paste the code in the arduino IDE
int x=0;
int y=0;
int z=0;
void setup() {
pinMode(A0,INPUT);
pinMode(A1,INPUT);
pinMode(A2,INPUT);
Serial.begin(9600);
}
void loop() {
x=analogRead(A0);
y=analogRead(A1);
z=analogRead(A2);
Serial.print("x=");
Serial.print(x);
Serial.print("y=");
Serial.print(y);
Serial.print("z=");
Serial.print(z);
Serial.print("\n\n");
}
Step 3:
Recording values on serial monitor
Conclusion:
As you move your hands you can see the value being printed on serial monitor.
These values change with respect to change in x, y, z co-ordinates.