Saturday, 1 September 2012

Week 5 FYP 2 : Design the Programming


  • The programming is design to control the servo motor which is the servo motor acts an output while the accelerometer acts as an input.




#include <Servo.h>

Servo leftServo, rightServo;

//Analog read pins
const int xPin = 0;
const int yPin = 1;
const int zPin = 2;

//The minimum and maximum values that came from
//the accelerometer while standing still
//You very well may need to change these
int minVal = 300;
int maxVal = 440;

//to hold the caculated values
double x;
double y;
double z;

void setup(){
  Serial.begin(9600);
  leftServo.attach(9);
  rightServo.attach(8);
}

void loop(){

  //read the analog values from the accelerometer
  int xRead = analogRead(xPin);
  int yRead = analogRead(yPin);
  int zRead = analogRead(zPin);

  //convert read values to degrees -90 to 90 - Needed for atan2
  int xAng = map(xRead, minVal, maxVal, -90, 90);
  int yAng = map(yRead, minVal, maxVal, -90, 90);
  //int zAng = map(zRead, minVal, maxVal, -90, 90);

  //Caculate 360deg values like so: atan2(-yAng, -zAng)
  //atan2 outputs the value of -Ï€ to Ï€ (radians)
  //We are then converting the radians to degrees
  //x = RAD_TO_DEG * (atan2(-yAng, -zAng) + PI);
  //y = RAD_TO_DEG * (atan2(-xAng, -zAng) + PI);
  z = RAD_TO_DEG * (atan2(-yAng, -xAng) + PI);

  //Output the caculations

  //Serial.print("x: ");
  //Serial.print(x);
  //Serial.print(" | y: ");
  //Serial.print(y);
  Serial.print(" | z: ");
  Serial.println(z);

  /*
  Serial.print("x: ");
  Serial.print(xRead);
  Serial.print(" | y: ");
  Serial.print(yRead);
  Serial.print(" | z: ");
  Serial.println(zRead);
  */

  //Left motor
  if ((z <= 40) && (z > 20))
  {
     leftServo.write(50);
  }
  else if ((z <= 20) && (z > 0))
  {
    leftServo.write(30);
  }
  else
  {
    leftServo.write(90);
  }
  /////////////////
  //right motor
  if ((z >= 120) && (z < 140))
  {
     rightServo.write(130);
  }
  else if ((z >= 140) && (z < 180))
  {
    rightServo.write(150);
  }
  else
  {
    rightServo.write(90);
  }
  delay(100);//just here to slow down the serial output - Easier to read
}





  • This is the arduino software that used to design a program. 
  • The software can be downloaded at www.arduino.cc


Arduino software to design a program



Saturday, 25 August 2012

Week 4 FYP 2 : Design the Flowchart


  • Flowchart for Arduino




Details on the component
Arduino Dueminalove

  • Arduino can sense the environment by receiving an input from a variety of sensors and can affect its surroundings by controlling lights, motors and other actuators.

Servo Motor                      
  • The nature of Servo motor which allow user to control its rotation angle
  • In this project, the servo motor will attached to the car's headlight in order to rotate the car headlight to a desired angle. 
  • The servo motor as an output



  •  It can measure the static acceleration of gravity in tilt-sensing applications, as well as dynamic acceleration resulting from motion
  • In this project, the accelerometer use as a motion sensor which it will attached to the car steering.
  • The accelerometer as an input.
                                                                     















Friday, 17 August 2012

Week 3 FYP 2 : Purchasing the Component


LIGHT ACTIVATED RELAY
Item No.
Product
Qty
Unit Price  
     Amount
1
RELAY 9V DC
1 PC
RM6.50
RM   6.50
2
RESISTOR :1K, 1K5 1/4W
3 PCS
RM0.10
RM   0.30
3
DIODE IN4007
1 PC
RM0.50
RM   0.50
4
ZENER DIODE 8.2V
1 PC
RM1.00
RM   1.00
5
TRANSISTOR BC547
1 PC
RM2.00
RM   2.00
6
TRANSISTOR BC557
1 PC
RM2.80
RM   2.80
7
NTC THERMISTOR
1 PC
RM8.00
RM   8.00
8
TRIMMER 100K
1 PC
RM5.00
RM   5.00
9
IC REGULATOR 7806
1 PC
RM2.50
RM   2.50
10
ELECTROLYTIC CAP 1000uF
1 PC
RM3.00
RM   3.00
11
SCREW BLK CONNECTOR 2 WAY
  1 PC
RM2.00
RM   2.00
12
SCREW BLK CONNECTOR 3 WAY
1 PC
RM3.00
RM   3.00
13
JUMPER WIRE & POWER  CABLE
1 PKT
RM5.00
RM   5.00
                                        TOTAL  :
RM   36.60


 PHOTOTRANSISTOR ACTIVATED SWITCH
1
RELAY 12V DC
1 PC
RM6.50
RM   6.50
2
DIODE IN4007
1 PC
RM0.50
RM   0.50
3
RESISTOR 1K, 2M7, 3K9,
4 PCS
RM0.10
RM   0.40
4
LED
1 PC
RM0.30
RM   0.30
5
TRANSISTOR  C1815
2 PCS
RM2.00
RM   4.00
6
TRIMMER 1M
1 PC
RM5.00
RM   5.00
7
PHOTOTRANSISTOR  PT-334-6C
1 PC
RM18.00
RM 18.00
8
SCREW BLK CONNECTOR 2 WAY
2 PCS
RM2.00
RM   4.00
9
SCREW BLK CONNECTOR 3 WAY
3 PCS
RM3.00
RM   9.00
11
JUMPER WIRE & POWER  CABLE
1 PKT
RM5.00
RM   5.00
                                        TOTAL  :
RM   52.70



1
ARDUINO DUEMILANOVE
1 PC
RM87.00
RM   87.00
2
SERVO MOTOR CYTRON C36R
2 PCS
RM40.00
RM   80.00
3
ACCELEROMETER-ADXL335
1 PC
RM120.00
RM   120.00
4
CAR BATTERY 12V 40A
1 PC
RM150.00
RM   150.00
                               TOTAL  :
RM   437.00



  • The total cost for all the component is RM526.30

Wednesday, 8 August 2012

Week 2 FYP 2 : Purchasing Proton Waja Headlamp



Waja Headlight
  • Bought Proton Waja headlamp for right side and left side
  • Each of the headlamp have 2 mentols
  • The mentols of the headlamp use 100 Watt for each mentol.
  • The total cost of the headlamp including mentols are RM 340

Thursday, 2 August 2012

Week 1 FYP 2 : Assign the circuit



Automatic Headlight Dimmer


  • Automatically switch from high to low beam when traffic approach to save others sight
  • With Q1 in moderate darkness the variable resistor must be adjusted to generate no base current through Q2 
  • This system is triggered by headlights from other car 
  • The high-beam lights on when there is no approaching headlights 
  • Headlights will be switched to low beams when the phototransisor receives lights from other car coming from the opposite direction



Automatic Light Controller


  • During night time, when no light falls on LDR1, it offers a high resistance at the base junction of transistor T1
  • So the bias is greatly reduced and T1 doesn’t conduct 
  • Effectively, this removes the common terminal of IC1 from ground and it directs the full input DC to the output 
  • Transistor T2 conducts and the relay energises to light up the bulb as mains connection completes through the relay contacts


Friday, 13 April 2012

Presentation Day (Week 12)

 During the presentation day, the assessor advised to me that the project should be divided into two parts. The first part is the operation of the headlight according to the ambient of light and the second part is the movement of the headlight according to the steering. The assessor advised me that the first part should be finished first before completing the second part. This is because the second part is involved with mechanical operation which   it will take more time to complete and deal with the mechanical problem.

Thursday, 5 April 2012

Prepare for the Presentation (Week 11)

 The presentation of FYP 1 is in week 12. The presentation should be consist of :


  • Introduction
  • Problem Statement
  • Objectives
  • Methodology
  • Benefits/ Contribution
  • Workplan
  • Conclusion