WELLCOME -----FYP S2 2011 PROJECT BLOG-----SUPERVISED BY: SIR KAMALUL FAIZIN B. MOHD SUHUT

Tuesday, April 19, 2011

PRESENTATION DAY!!!!

Firstly thanks to ALLAH, for He always there for us giving me strength to this very day to write about my viva day. Okay it was not that good, since I was preparing the for only the technical stuff, electronics, and the hardware parts. Our project assessor, Sir Samsul was giving us a hard time, testing our medical knowledge. Well it goes without saying that OBVIOUSLY I can't confidently answer his questions. Some of it I got it right, but all and all he was confident that we are the one that have lose our sharpness. He told us to go back to study  medical.Wait. Study it from the SPM level. OUCH. 
Em.. Enough about my viva, let;s get uploading! :)
Okay I am about to upload my precious sketch. So Here you go guys, hope it'll help u as it helped me. :)

SENDER (XBEE TRANSMITTER)

/*Sketch ini dibuat utk menghanatar signal dr analog pin Uno 1 
ke UNO 2 utk mendisplay bubble detected ke LCD display sambil 
membunyikkan buzzer. Insyallah. */

int sensorPin = A0; 
int sensorValue = 0;
const int ledPin = 13;   //PIN 13 DA MMG ADE LAMPU LED
#include <Stepper.h>
#define STEPS 100
Stepper motor1(STEPS, 8, 9, 10, 11);
void setup()
{
  Serial.begin(19200);
  motor1.setSpeed(20);
}

void loop()
{
  //motor1.step(1*STEPS);
  //delay(2000);
  motor1.step(-1*STEPS);
  delay(2000);
  //baca analog inout dr bubble detector
  sensorValue = analogRead(sensorPin);
  //remap value utk mencantikkan signal bubble yg dikesan
  sensorValue = map(sensorPin, 0, 1023, 253, 0);
  

if ((int(incomingByte) <80)) //ni utk keadaan biasa, iaitu bila ade fluid
  {
  Serial.print(255,BYTE); //

  Serial.print(sensorValue,BYTE);
  digitalWrite(ledPin, HIGH);
  }

  if ( sensorValue > 150) //150 adalah bersamaan dgn 3Volt.
  {
  Serial.print(254,BYTE); //
  Serial.print(sensorValue,BYTE);
  digitalWrite(ledPin, LOW);
  }
  else 
  {
    digitalWrite(ledPin, HIGH); //YG NI utk aku tunjuk bahawa xde ape2 
  }
  delay(150);
}

RECEIVER (XBEE RECEIVER)

/* Skecth ini pula dibuat utk menerima data dr UNO 1 yg ada bubble 
detector, dan menyuruh LCD, BUZZER asalarm indicators. Insyallah.. 
TP FIRST NAK TEST PAKAI LCD LA DULU  */

#include <LiquidCrystal.h>
int speakerPin = 5;
byte incomingByte, sensor1;

//LCD saya memakai pin Uno 2 yg berikut:
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

void setup() 
  {
  Serial.begin(19200);
  pinMode (13, OUTPUT);
  pinMode(speakerPin, OUTPUT);
  (" Ready! ");
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("Monitoring: OK");
  lcd.setCursor(0, 1);
  lcd.print("BED 2");
  delay(1000);
  }

void loop() {
if (Serial.available()) 
{
incomingByte = Serial.read();

Serial.print(int(incomingByte));

if ((int(incomingByte) <80)) //ni utk keadaan biasa, iaitu bila ade fluid
  {
    sensor1 = Serial.read();
    lcd.clear();
    lcd.print("LINE CLEAR");
    Serial.print(int(sensor1));
    digitalWrite(13, LOW);
  }

if ((int(incomingByte) > 150)) //150 utk detect 3V, sbb kalo de bubble voltan akan naik smpai ke 3V.
  { 
  sensor1 = Serial.read(); //x de pon x pe kot??ntah
  digitalWrite(speakerPin, HIGH);
  delay(500);
  digitalWrite(speakerPin, LOW);
  delay(500);
  lcd.clear();
  lcd.print("BUBBLE DETECTED!!"); 
  Serial.print(int(sensor1));
  digitalWrite(13, HIGH);
  }
}

   for (int positionCounter = 0; positionCounter < 13; positionCounter++) {
   // scroll one position left:
   lcd.scrollDisplayLeft(); 
   // wait a bit:
   delay(250);
  }

  // scroll 29 positions (string length + display length) to the right
  // to move it offscreen right:
  for (int positionCounter = 0; positionCounter < 29; positionCounter++) {
    // scroll one position right:
    lcd.scrollDisplayRight(); 
    // wait a bit:
    delay(250);
  }
  
    // scroll 16 positions (display length + string length) to the left
    // to move it back to center:
    for (int positionCounter = 0; positionCounter < 16; positionCounter++) {
    // scroll one position left:
    lcd.scrollDisplayLeft(); 
    // wait a bit:
    delay(250);
  }
  
    // delay at the end of the full loop:
    delay(1000);
    digitalWrite (13, sensor1);
}

Both above sketches are done using XBEE Shield, so note that other XBEE may not work with this program. Also, the sketches is actually made to detect bubble from the infra red, (A0) and convert it into digital input. The ADC function has been done by MAPPING FUNCTION BY THE ARDUINO. So no need for ADC IC. (Cool eh?)

GOOD LUCK FOR THURSDAY PEEPS!!! :)



Monday, April 18, 2011

FINAL TOUCH

Okay right now I really shouldn't be writing to the blog, but I think I'll regret it if I didn't. Last touch for the project, we are working on the hardware for the prototype. Hilwani is mounting the motor to the proto board, and I am working on the ARDUINO WHOLE SYSTEM SKETCHES. I'll update the pictures tomorrow. 

Still, we are not done. There are some missing points that we haven't touch but at least there are some things that are succeed thanks to ALLAH.

Lastly, pray for us. Good luck to our friends also, La Tahzan, for Allah is always with you. :)