Monday, October 19, 2015

ARTICLE #8 Control a Servo Motor Using Infrared Receiver Sensor and Remote Control

Circuit wiring :

     Project parts :


To realize this project you will need :

  •       1 Arduino Uno.
  •       1 Breadboard.
  •       1 IR Receiver Sensor ( TSOP38238).
  •       1 Mini Remote Control.
  •       1 Servo Motor.
  •       Connector wires.



     Wiring :





Code

#include <IRremote.h>
#include <Servo.h>

int RECV_PIN = 5;

Servo servo;
IRrecv irrecv(RECV_PIN);      
decode_results results; 
int i=0;

void setup() {


  servo.attach(9);

  servo.write(0);
  Serial.begin(9600);         
  irrecv.enableIRIn();

}


void loop() {


    if(irrecv.decode(&results)) {  


    Serial.println(results.value, HEX);


        if(results.value == 0xFD609F){


             i+=10;

             servo.write(i);
             delay(200);

    }


       if(results.value == 0xFD20DF){


             i-=10;

             servo.write(i);
             delay(200);

    } 


    irrecv.resume(); 


  }


  delay(50);


}

Sunday, October 11, 2015

ARTICLE #7 Tilt sensor

What is a tilt sensor ?



Next time when you play Tomb Raider on your PS3, you are controlling the movements of Lara Croft with the analogue joystick, remember that you are using a bunch of tilt sensors.These sensors allow the movement of your thumb on the joystick be transformed into the movements you see on the screen when you are playing.



The tilt sensor, usually called tilt switch, is a small low-power 2-pin electrical device that simply indicates if a system is inclined or not in reference to earth’s surface. It is its simplicity that made it popular for many applications in robotics, Aircraft Flight Controls, automotive systems …etc.



In this article, we will explore in depth the functioning of the tilt sensor by making a simple project. But first, here are some features of this device.




Some features of the tilt sensor :


How does a tilt sensor work :


Circuit wiring :


     Project parts :



To realize this project you will need :

  • 1 Arduino Uno.
  • 1 Breadboard.
  • 1 Tilt sensor.
  • 1 LED.
  • 2 Resistors.
  • Connector wires.


     Wiring :


In this project, the tilt sensor can sense the orientation of the circuit. It turns the LED on when the circuit is turned upside down.

Connect the parts of the circuit as seen in the picture below. 

Notice that I connected the tilt sensor pin to a pull-up resistor. So the pin takes the logic value “1” when the switch is open and value “0” when the switch is closed.





Code :


int led = 10;
int tilt = 4;

void setup() {

  pinMode(led, OUTPUT);
  pinMode(tilt, INPUT);

}

void loop() {

  int tiltVal = digitalRead(tilt);

  if(tiltVal == 1)
  digitalWrite(led, HIGH);  
  else            
  digitalWrite(led, LOW);    

}