Sunday, December 15, 2013

Contribution:
The whole team worked as one person; we all had one goal which was to achieve and design a mechanism, so we can say that everyone in the group worked as much hard everyone else in the group. 

On the presentation day, 

Here is another code for servo, LEDS, LCD, temperature sensor, dc motor


#include <Servo.h>
Servo myservo;
int tempIn = 0;       // temperature sensor on Analogue Pin 3
int ledOut = 8;       // LED on Digital Pin 8
int LedOut1 = 10;      // LED on Digital Pin 10
int aiValue = 0;       // input value (0-1023 = 0 to 5v)
float setPoint = 30;    // Trigger value in 'C
float deadband = 0.5; // Differential for reset value in 'C
int potpin = 0;
int val;
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5,4,3,2);
const int buttonPin =  1;
const int MotorPin = 7;
int x=0;
/*
  NOTE: the deadband action can be disabled by setting the deadband to 0
 */
float degC;            // The temperature in Degrees Centigrade
void setup(){
  {
    pinMode(ledOut, OUTPUT);  // Configure the Digital Pin Direction for the LED
    pinMode(LedOut1, OUTPUT);
    lcd.begin(16, 2);
    lcd.clear();
    Serial.begin(9600);
  }
  {
    myservo.attach(9); // attaches the servo on pin 9 to the servo object
  }
  {
    pinMode(buttonPin, INPUT);
    pinMode(MotorPin, OUTPUT);
  }
}
void loop()
{

  degC = getTemperature(getVolts());      //Get the Volts and the Temperature using Helper functions.

  if (degC > setPoint)
  {
    digitalWrite(ledOut, HIGH);      // Temperature Limit Reached, turn the LED on.
    Serial.println(" | Output: ON.");
    lcd.setCursor(0,1);
    lcd.print("  Yellow  ");
    lcd.print(degC);


  }
  else
  {
    if (degC > (setPoint - deadband))
    {
      digitalWrite(ledOut, LOW);       // Temperature dropped below SP and deadband, turn the LED off.
      Serial.println(" | Output: OFF.");
      lcd.print("      ");
    }
  }
  if (degC < setPoint)
  {
    digitalWrite(LedOut1, HIGH);      // Temperature Limit Reached, turn the LED on.
    Serial.println(" | Output: ON.");
    lcd.setCursor(0,1);
    lcd.print("  RED   ");
    lcd.print(degC);
  }
  else
  {
    if (degC < (setPoint - deadband))
    {
      digitalWrite(LedOut1, LOW);       // Temperature dropped below SP and deadband, turn the LED off.
      Serial.println(" | Output: OFF.");
      lcd.print("      ");
    }
  }

  delay(1000);

  {
    val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
    val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
    myservo.write(val); // sets the servo position according to the scaled value
    delay(15); // waits for the servo to get there
  }
  {
    x=digitalRead(buttonPin);
    if(x==HIGH){
      digitalWrite(MotorPin,LOW);
    }
    else{
      digitalWrite(MotorPin,HIGH);
    }
  }
}
/*
Return the voltage for the input value; 0-1023 = 0 to 5V
 */
float getVolts()
{
  int inputValue;
  inputValue = analogRead(tempIn);
  float volts;
  volts = (((float)inputValue / 1024) * 5);

  Serial.print("Input Value: ") ;
  Serial.print(inputValue);
  Serial.print(" | Voltage: ") ;
  Serial.print(volts);
  return volts;
}
/*
Return the temperature in DegreesC for given voltage
 */
float getTemperature(float volts)
{
  float temp = (volts - 0.5) / 0.01 ;

  Serial.print(" | Temperature: ");
  Serial.print(temp);
  Serial.print(" 'C");

  return temp;
}

Wednesday, December 4, 2013


The DC motor drives the fan on the boat, and the servo drives the rudder. We plan on using a potentiometer to control the servo, and a push button to control the DC motor.
The team is meeting now, on Nov. 22, 2013. We are all working on building a boat. The solidworks of the boat is almost completed and we are working on various codes for the dc motor, servo, and LCD screen with the LED lights.

We are designing a boat that can be controlled by a DC motor, and a servo. We are also including a red LED to indicate that temperature is below some certain temperature (a temperature that we can set). We are also including a yellow LED to show that the temperature is now above the set temperature. Both action ( red or yellow) are going to be shown on a LCD with the current temperature at that moment.
hardware: 
1. temperature sensor.
2. LCD (16x2)
3. a red LED.
4. a yellow LED
5. potentiometer
6.  2 resistor.
 7. wires.
code:    
/*
Basic Analogue Input Control - Temperature Sensor
This example reads an analogue value from analogue in pin 1 and then compares this to a set point.
If the set point is threshold is crossed, the LED on digital pins 8,9 is turned on/off. A deadband is
provided to prevent high speed toggling at the set point transition.
The logic used below with act on Rising temperature.
The analogue input will come from a TMP36 temperature sensor.
-40'C to 125'C = 100mV to 1750mv (linear 10mV per 'C)
*/
int tempIn = 0;       // temperature sensor on Analogue Pin 3
int ledOut = 8;       // LED on Digital Pin 8
int LedOut1 = 9;      // LED on Digital Pin 9
int aiValue = 0;       // input value (0-1023 = 0 to 5v)
float setPoint =30;    // Trigger value in 'C
float deadband = 0.5;   // Differential for reset value in 'C
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5,4,3,2);
/*
  NOTE: the deadband action can be disabled by setting the deadband to 0
*/
float degC;            // The temperature in Degrees Centigrade
void setup()
{
  pinMode(ledOut, OUTPUT);  // Configure the Digital Pin Direction for the LED
  pinMode(LedOut1, OUTPUT);
  lcd.begin(16, 2);
  lcd.clear();
  Serial.begin(9600);
}
void loop()
{

  degC = getTemperature(getVolts());      //Get the Volts and the Temperature using Helper functions.
   
  if (degC > setPoint)
  {
    digitalWrite(ledOut, HIGH);      // Temperature Limit Reached, turn the LED on.
    Serial.println(" | Output: ON.");
     lcd.setCursor(0,1);
     lcd.print("  Yellow  ");
     lcd.print(degC);
   
   }
    else
  {
      if (degC > (setPoint - deadband))
      {
      digitalWrite(ledOut, LOW);       // Temperature dropped below SP and deadband, turn the LED off.
      Serial.println(" | Output: OFF.");
      lcd.setCursor(0,1);
      lcd.print("      ");
      }
  }
   if (degC < setPoint)
  {
    digitalWrite(LedOut1, HIGH);      // Temperature Limit Reached, turn the LED on.
    Serial.println(" | Output: ON.");
    lcd.setCursor(0,1);
    lcd.print("  RED   ");
    lcd.print(degC);
   }
    else
  {
      if (degC < (setPoint - deadband))
      {
      digitalWrite(LedOut1, LOW);       // Temperature dropped below SP and deadband, turn the LED off.
      Serial.println(" | Output: OFF.");
      lcd.setCursor(0,1);
      lcd.print("      ");
      }
  }
  
  delay(1000);
}
/*
Return the voltage for the input value; 0-1023 = 0 to 5V
*/
float getVolts()
{
  int inputValue;
  inputValue = analogRead(tempIn);
  float volts;
  volts = (((float)inputValue / 1024) * 5);
 
  Serial.print("Input Value: ") ; Serial.print(inputValue);
  Serial.print(" | Voltage: ") ; Serial.print(volts);
  return volts;
}
/*
Return the temperature in DegreesC for given voltage
*/
float getTemperature(float volts)
{
  float temp = (volts - 0.5) / 0.01 ;
 
  Serial.print(" | Temperature: "); Serial.print(temp); Serial.print(" 'C");
 
  return temp;
}
some images:

 

Tuesday, November 12, 2013

nov,12


On 11-12-3013, the team met again, and we decided to do the followings:

Mechanism: a vehicle  
we also decide to creates Circuits that includes a servo motor, L293D motor driver, Plastic gear motors, Wheels compatible with plastic gear motors, Castor wheel, Sharp GP2D12 analog distance sensor, LED, LCD, push buttons,potentiometer. 

#example code:

   #include <Servo.h> //includes the servo library

int motor_pin1 = 4;
int motor_pin2 = 5;
int motor_pin3 = 6;
int motor_pin4 = 7;
int servopin = 8;
int sensorpin = 0;
int dist = 0;
int leftdist = 0;
int rightdist = 0;
int object = 500;             //distance at which the robot should look for another route                           

Servo myservo;

void setup ()
{
  pinMode(motor_pin1,OUTPUT);
  pinMode(motor_pin2,OUTPUT);
  pinMode(motor_pin3,OUTPUT);
  pinMode(motor_pin4,OUTPUT);
  myservo.attach(servopin);
  myservo.write(90);
  delay(700);
}
void loop()
{
  dist = analogRead(sensorpin);               //reads the sensor
 
  if(dist < object) {                         //if distance is less than 550
   forward();                                  //then move forward
  }
  if(dist >= object) {               //if distance is greater than or equal to 550
    findroute();
  }
}
 
void forward() {                            // use combination which works for you
   digitalWrite(motor_pin1,HIGH);
   digitalWrite(motor_pin2,LOW);
   digitalWrite(motor_pin3,HIGH);
   digitalWrite(motor_pin4,LOW);
   return;
 }
 
void findroute() {
  halt();                                             // stop
  backward();                                       //go backwards
  lookleft();                                      //go to subroutine lookleft
  lookright();                                   //go to subroutine lookright
                                      
  if ( leftdist < rightdist )
  {
    turnleft();
  }
 else
 {
   turnright ();
 }
}

void backward() {
  digitalWrite(motor_pin1,LOW);
  digitalWrite(motor_pin2,HIGH);
  digitalWrite(motor_pin3,LOW);
  digitalWrite(motor_pin4,HIGH);
  delay(500);
  halt();
  return;
}

void halt () {
  digitalWrite(motor_pin1,LOW);
  digitalWrite(motor_pin2,LOW);
  digitalWrite(motor_pin3,LOW);
  digitalWrite(motor_pin4,LOW);
  delay(500);                          //wait after stopping
  return;
}
 
void lookleft() {
  myservo.write(150);
  delay(700);                                //wait for the servo to get there
  leftdist = analogRead(sensorpin);
  myservo.write(90);
  delay(700);                                 //wait for the servo to get there
  return;
}

void lookright () {
  myservo.write(30);
  delay(700);                           //wait for the servo to get there
  rightdist = analogRead(sensorpin);
  myservo.write(90);                                  
  delay(700);                        //wait for the servo to get there
  return;
}

void turnleft () {
  digitalWrite(motor_pin1,HIGH);       //use the combination which works for you
  digitalWrite(motor_pin2,LOW);      //right motor rotates forward and left motor backward
  digitalWrite(motor_pin3,LOW);
  digitalWrite(motor_pin4,HIGH);
  delay(1000);                     // wait for the robot to make the turn
  halt();
  return;
}

void turnright () {
  digitalWrite(motor_pin1,LOW);       //use the combination which works for you
  digitalWrite(motor_pin2,HIGH);    //left motor rotates forward and right motor backward
  digitalWrite(motor_pin3,HIGH);
  digitalWrite(motor_pin4,LOW);
  delay(1000);                              // wait for the robot to make the turn
  halt();
  return;
}



The team’s name is ardunio801 which consists from Abdel R Shawish, Kylee Maclnnis, and Jake Reed.
Some possible ideas (soildworks} :
-          A desktop fan.
-          A boat
-          A go-kart
-          A car

     For ardunio:

We decided to use all required parts such as servo motor, a DC motor, LED, LCD, push buttons, Potentiomete.