RPI-1031 Angle Sensor Four Direction Sensor (RPI-1031) [S183]



https://www.youtube.com/watch?v=supbSTUcWpw


*GitHubhttps://github.com/rdiot/rdiot-s183.git


* Specs

1. Optical principle: There are one infrared LED and two photosensitive triode receiver and a cylindrical shade inside as picture.

2. The status of RPI-1031 is controlled by cylindrical shade between infrared LED and receiver.

3. AS show,infrared is blocked.So two receivers can not receive signal.So sensor's status is OFF as low level and both output low level.

4. AS show,one receiver is blocked so it can receive signal and it output low level.Otherside,another receiver's status is ON,so it output high level.

5. AS show,LED or receiver are not blocked both,so output two high level.


* Contents

- Connect

5V ----- 5V

S1 ----- D2

S2 ----- D3

GND ----- GND


' LED

TOP ----- D8

RIGHT ----- D9

BOTTOM -----  D10

LEFT ----  D11



- Key Code

//For the RPI-1031 - http://www.sparkfun.com/products/10621

int tilt_s1 = 2;

int tilt_s2 = 3;

int led_top = 8;

int led_right = 9;

int led_bottom = 10;

int led_left = 11;


void setup(){

 pinMode(tilt_s1, INPUT);

 pinMode(tilt_s2, INPUT);

 pinMode(led_top, OUTPUT);

 pinMode(led_right, OUTPUT);

 pinMode(led_bottom, OUTPUT);

 pinMode(led_left, OUTPUT);

  

 Serial.begin(9600);

}

void loop(){

  int position = getTiltPos();

  Serial.println(position);

  //top

  if(position == 0)

  {

    digitalWrite(led_top, HIGH); 

    digitalWrite(led_right, LOW);

    digitalWrite(led_bottom, LOW);

    digitalWrite(led_left, LOW);

  }

  //right

  else if(position == 2)

  {

    digitalWrite(led_top, LOW); 

    digitalWrite(led_right, HIGH);

    digitalWrite(led_bottom, LOW);

    digitalWrite(led_left, LOW);

  }

  //left

  else if(position == 1)

  {

    digitalWrite(led_top, LOW); 

    digitalWrite(led_right, LOW);

    digitalWrite(led_bottom, LOW);

    digitalWrite(led_left, HIGH);

  }

  //bottom

  else if(position == 3)

  {

    digitalWrite(led_top, LOW); 

    digitalWrite(led_right, LOW);

    digitalWrite(led_bottom, HIGH);

    digitalWrite(led_left, LOW);

  }  

  delay(200); //only here to slow down the serial output

}


int getTiltPos(){

   int s1 = digitalRead(tilt_s1);

   int s2 = digitalRead(tilt_s2);

   return (s1 << 1) | s2; //bitwise math to combine the values

}

Posted by RD IoT RDIoT

댓글을 달아 주세요

Tilt Switch Module (KY-020) [S050]



https://www.youtube.com/watch?v=dVq5xSTB9S8


*GitHubhttps://github.com/rdiot/rdiot-s050.git


* Specs

Tilt sensor

Working voltage: 3.3V~5V

Digital Switch Output (0 & 1)

High sensitivity

With fixed bolt hole for easy installation

Works with Official Arduino Boards

Forum link: https://www.facebook.com/123Neonado

Material: PCB

Dimensions: 25 x 16 x 8 mm / 0.98 x 0.63 x 0.31 inch

Weight: 1 g / 0.04 oz

Color: Black


* Contents

- Connect

S ----- D2

middle ----- 5V

- ----- GND


- Key Code

#include <Wire.h> 

#include <LiquidCrystal_I2C.h>

 

LiquidCrystal_I2C lcd(0x27,20,4);  // LCD2004

 

int pin = 2;

int val = digitalRead(pin);

 

  if(val == LOW)

  { 

    lcd.setCursor(0,2);

    lcd.print("Tilt CLOSE");

  }

  else

  {

    lcd.setCursor(0,2);

    lcd.print("Tilt OPEN ");  

  }

Posted by RD IoT RDIoT

댓글을 달아 주세요

Mini Mercury Switch Module (KY-017) [S049]



https://www.youtube.com/watch?v=TzuxDa6xQ-g


*GitHubhttps://github.com/rdiot/rdiot-s049.git


* Specs

Working voltage: 3.3V~5V

digital switch output (0 & 1)

High sensitivity

With fixed bolt hole for easy installation

Works with Official Arduino Boards

Application: For Arduino DIY project

Forum link: https://www.facebook.com/123Neonado

Material PCB

Dimensions: 31 x 15 x 8 mm / 1.22 x 0.59 x 0.31 inch

Weight: 2 g / 0.07 oz

Color: Black


* Contents

- Connect

- ----- GND

middle ----- 5V

S ----- D2


- Key Code

int pin = 2;

int val = digitalRead(pin);


  if(val == LOW)

  { 

    lcd.setCursor(0,2);

    lcd.print("Tilt CLOSE");

  }

  else

  {

    lcd.setCursor(0,2);

    lcd.print("Tilt OPEN ");  

  }

Posted by RD IoT RDIoT

댓글을 달아 주세요

Tilt SW-520D Sensor (SW-520D) [S067]



https://www.youtube.com/watch?v=AbBB5RE9uQs


*GitHubhttps://github.com/rdiot/rdiot-s067.git


* Specs

Max voltage : 20V 

Max current : 0.3A


* Contents

- Connect

1 ---- 5V

2 ----- R220 ----- D2

           ------ GND


- Key Code

int pin = 2;

int val = digitalRead(pin);


if(val == LOW)

  lcd.setCursor(0,2);

  lcd.print("Tilt CLOSE");

}

else

{

  lcd.setCursor(0,2);

  lcd.print("Tilt OPEN ");  

}

Posted by RD IoT RDIoT

댓글을 달아 주세요

Tilt SW-200D Sensor (W-200D) [S051]



https://www.youtube.com/watch?v=Awp-0iWdAm4


*GitHubhttps://github.com/rdiot/rdiot-s051.git


* Specs

the switch using metal manufacturing, electrical characteristics and mercury switches are similar but not the risk of mercury switches and environmental issues, while shaking unidirectional conducting the same characteristics, the assembly of the use of more convenient and safe;

Operating Characteristics: Switch in the stationary state, as shown in Figure (ON) side below the level of 15 degrees, the switch is in the ON state; when (OFF) side below the level of 15 degrees, the switch is in the OFF state; when achieved by external shaking shaking force, or set the conduction angle, the conductive pin electrical characteristics will produce short or continuous conduction.

when the electrical characteristics of the open state to be restored (OFF) when the switch is set to the environment must be static, and the (OFF) is set to be lower than the level of the open end angle;

the switch all materials are manufactured using environmentally friendly raw materials, in line with ROHS requirements;

when the switch below the horizontal angle of 15 degrees, shaking hard trigger conduction;

the trigger switch for low current circuit, does not apply when the power switch;

this switch is a sealed package, dustproof and waterproof.

The switch is lacoste type better than the single bead type conduction effect


Maximum operating voltage (Vmax): 12V

Maximum operating current (Imax): 2mA

Open resistance: greater than 10M

Resistance: less than 5 ohm

Ambient temperature: less than 100 degrees

Life: 500,000 times


* Contents

- Connect

1 ---- 5V

2 ----- R220 ----- D2

           ------ GND


- Key Code

int pin = 2;

int val = digitalRead(pin);


if(val == LOW)

  lcd.setCursor(0,2);

  lcd.print("Tilt CLOSE");

}

else

{

  lcd.setCursor(0,2);

  lcd.print("Tilt OPEN ");  

}

Posted by RD IoT RDIoT

댓글을 달아 주세요