Gyroscope Sensor
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:
- An Arduino, we will be using Arduino Uno.
- GY-61 3-AXIS accelerometer module
- Jumper wires
Steps:
Step 1:
Connecting accelerometer module gy-61 with Arduino
Accelerometer module contains 5 pins:
- VCC
- x-axis
- y-axis
- z-axis
- GND
Connections:
- connect VCC with 5V pin of Arduino
- connect X pin with A0 pin of Arduino
- connect Y pin with A2 pin of Arduino
- connect Z pin with A3 pin of Arduino
- connect GND with GND pin of Arduino
- We will be using a0 pin and a4 pin as VCC and GND pin respectively.
- X, Y, Z are connected to A1, A2, A3 to receive digital input from sensor.
Step 2:
Paste the code in the arduino IDE
- copy the code below and paste it into 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
- Open serial monitor on Arduino IDE
- Move the sensor in different directions
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.