ARDUINO RPI-1031 4 Direction Sensor

ARDUINO RPI-1031 4 Direction Sensor

Operating Principle

  1. Based on optics principles.its interior has LED for 1 pc,photosensitive receiving triode for 2pcs;and the other side has one cylindrical shade;just as the picture shows:
    Operating Principle
    Circuit Diagram
    Circuit Diagram
  2. By cylindrical shade to keep out the LED,and photosensitive receiving tube is for detecting RPl-1031 current state.
    Operating Principle
  3. When RPl-1031 rotates to the state shown as below,LED is shadowed by the shade;and two photosensitive receiving triodes cannot receive the light;they will be in off state.output low level;two GPIO ports both output low level.
    Operating Principle
  4. When RPl-1031 rotates to the state shown as below,one of the photosensitive triode was shadowed,the light emitted by LED only can be received by the other one;that means above photosensitive triode is on,and photosensitive triode under side is off;then two GPIO ports output respectively output high level and low level.
    Operating Principle
  5. When RPl-1031 rotates to the state shown as below,the shade does not shadow the diode will shine,two photosensitive triodes can receive the light;then all of them will be on.both of two GPIO ports output high level.
    Operating Principle
  6. When RPl-1031 rotates to the state shown as below.this state is adverse to description 4 two GPIO ports output level will be inter cahnged.

Figure 2: Sample connections.
Sample Connections

Sample Codes

I*
e-Gizmo RPl-1031 Angle sensor 4 Direction sensor
This is a sample sketch for Tilt direction sensor to display the sensor output positions.
For the RPl-1031 – http://www.sparkfun.com/products/10621
Modified by e-Gizmo Mechatronix Central
http://www.e-gizmo.com
July 18,2017
*I
#define TILT S1 4
#define TILT_S2 5
#define LED_ TOP 8
#define LED RIGHT 9
#define LED BOTTOM 10
#define LED_LEFT 11
void setup{){
}
Serial.begin(9600);
pinMode(TILT_S1, INPUT);
pinMode(TILT_S2, INPUT);
pinMode(LED TOP, OUTPUT);
pinMode(LED RIGHT, OUTPUT);
pinMode(LED_BOTTOM, OUTPUT);
pinMode(LED_LEFT, OUTPUT);
void loop{){
int position = GET_ TILT POSITION();
Serial.println(position);
//TOP
if(position == 0)
{
}
digitalWrite(LED_TOP, HIGH);
digitalWrite(LED_RIGHT, LOW);
digitalWrite(LED BOTTOM, LOW);
digitalWrite(LED LEFT, LOW);
//RIGHT
if(position == 2)
{
digitalWrite(LED TOP, LOW);
digitalWrite(LED_RIGHT, HIGH);
digitalWrite(LED BOTTOM, LOW);
digitalWrite(LED_LEFT, LOW);
void loop{){
int position = GET_ TILT POSITION();
Serial.println(position);
//TOP
if(position == 0)
{
}
digitalWrite(LED_TOP, HIGH);
digitalWrite(LED_RIGHT, LOW);
digitalWrite(LED BOTTOM, LOW);
digitalWrite(LED LEFT, LOW);
//RIGHT
if(position == 2)
{
digitalWrite(LED TOP, LOW);
digitalWrite(LED_RIGHT, HIGH);
digitalWrite(LED BOTTOM, LOW);
digitalWrite(LED_LEFT, LOW);
}
//LEFT
if(position == 1)
{
}
digitalWrite(LED TOP, LOW);
digitalWrite(LED_RIGHT, LOW);
digitalWrite(LED BOTTOM, LOW);
digitalWrite(LED_LEFT, HIGH);
//BOTTOM
if(position == 3)
{
}
digitalWrite(LED TOP, LOW);
digitalWrite(LED RIGHT, LOW);
digitalWrite(LED_BOTTOM, HIGH);
digitalWrite(LED LEFT, LOW);
delay(200); //DELAY
}
int GET_TILT_POSITION(){
int S1 = digitalRead(TILT_S1);
int S2 = digitalRead(TILT _S2);
return (S1 << 1) I S2; //BITWISE MATH
}

Figure 3: Serial print output from pH sensor.
Serial Print Output From pH Sensor

Logo

Documents / Resources

ARDUINO RPI-1031 4 Direction Sensor [pdf] User Manual
RPI-1031 4 Direction Sensor, RPI-1031, 4 Direction Sensor, Direction Sensor, Sensor

References

Leave a comment

Your email address will not be published. Required fields are marked *